Issue
I have a table on a web page that its xpath differs from time to time but its class name doesn't. so I can handle it by its class name but my code needs the xpath of that element so how to get the xpath of that element? OR how to deal with such elements that its xpath differs from time to time?
String xpath = "here sould be the xpath of that element";
wait_page_loading(By.xpath(table_xpath)); //this other function in my class wait the page loading
WebElement Webtable = driver.findElement(By.xpath(table_xpath));
List<WebElement> totalRowCount = Webtable.findElements(By.xpath(table_xpath + "/tbody/tr"));
if(totalRowCount.size() <= 1) {
throw new Exception("Can't find results in the problem page");
}
return totalRowCount.get(0).findElements(By.xpath("td")).get(6).getText();
Thanks a lot in advance.
Solution
I see a div and then we have a child table, please use the below xpath :
//div[@class='table-responsive']/table
Answered By - cruisepandey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.