When searching for input, multiple table data is retrieved. A "show as text link" is present in different table rows that needs to be clicked.
I wrote a code that works fine in IE on one machine but does not work on a different machine due to variations in monitor size!
String rawTextXpath = "//table[@id='view518-table']/tbody/tr[1]/td[4]/div[1]/a[text()='Show as raw text']";
boolean exists = false;
exists = driver.findElements(By.xpath(rawTextXpath)).size() != 0;
if (exists == false) {
system.out.println("No Results found!");
}
int i = 1;
while (exists == true) {
try {
driver.findElement(By.xpath(rawTextXpath)).click();
Thread.sleep(3000);
}
catch (Exception e) {
}
String expandXpath = "//table[@id='view518-table']/tbody/tr[" + i + "]/td[1]/a";
driver.findElement(By.xpath(expandXpath)).click();
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("window.scrollBy(0,150)", "");
rawTextXpath = "//table[@id='view518-table']/tbody/tr[" + (i + 1)
+ "]/td[4]/div[1]/a[text()='Show as raw text']";
exists = driver.findElements(By.xpath(rawTextXpath)).size() != 0;
i++;
}
Note: In the script above, I scroll the webpage by 150 units which works fine in IE on one machine, but not in the same browser on a different system.
Steps: 1. Click on the show as text link in each table row and then click on the expand icon
The above code does not function properly in a different system using the same IE11 browser because of varying monitor sizes!