12
Mar

title

Serialization / Deserialization of HashMap in java
    String name = "JackychanAdventuresJJ";

    Map<Character, Integer> map = new LinkedHashMap<>();

    for (Character c : name.toCharArray()) {
        map.put(c, map.containsKey(c) ? (map.get(c) + 1) : 1);
    }

    System.out.println(map);

    try {
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("C:\\abc.ser"));
        oos.writeObject(map);
        oos.close();

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("C:\\abc.ser"));
        Map<Character, Integer> mapD = (Map<Character, Integer>) ois.readObject();
        for (Map.Entry<Character, Integer> me : mapD.entrySet()) {
            System.out.print(me.getKey() + "::" + me.getValue());
        }

    } catch (IOException | ClassNotFoundException e) {

        e.printStackTrace();
    }

http://defectracker.com/wp-content/uploads/2020/04/testEvergreen.txt

		//First Keyword:
		WebElement el = driver.findElement(By.xpath("//*[contains(text(), 'Equity Compensation Plans')]"));
		WebElement sl = driver.findElement(By.xpath("//*[contains(text(), 'automatically increase')]"));
		
		String firstElementText = el.getAttribute("innerHTML");	
		String entireText = driver.getPageSource();
		
		int pos = entireText.indexOf(firstElementText);
		System.out.println("Found position at "+pos+"  "+entireText.length());
		firstElementText = entireText.substring(pos,entireText.length()-1);
		System.out.println(firstElementText.contains(sl.getAttribute("innerHTML")));


===========

	private static WebElement myFunction(WebDriver driver, String tag, String text) {
		WebElement foundElement = null;
		List<WebElement> list = driver.findElements(By.tagName(tag));
		for (WebElement element : list) {
			String outerHTML = element.getAttribute("outerHTML");
			outerHTML = outerHTML.replaceAll("&nbsp;", " "); // replace all &nsbp with " "
			outerHTML = outerHTML.replaceAll("\\r\\n|\\r|\\n", " "); // replace all newline chars
			outerHTML = outerHTML.replaceAll("\\<.*?\\>", ""); // replace all html tags
			outerHTML = outerHTML.trim();
			if (outerHTML.contains(text)) {
				System.out.println(outerHTML);
				foundElement = element;
				break;
			}
		}
		return foundElement;
	}

		WebElement x = myFunction(driver, "td", "Equity compensation plans not approved by stockholders");