I want to select several elements on a site and iterate through them. Of these elements I want to find nested elements with xpath.
List<WebElement> elements = driver.findElements(By.className("aagrRow"));
for(WebElement we: elements){
System.out.println(we.findElement(By.xpath("(//td[@class=\"spreadsheet\"])[24]")).getText());
}
The problem I have is that xpath doesnt seem to search inside the we-element but from the root of the document. What can I do?
Try this. You need to start with a period at the beginning.
By.xpath("(.//td[@class=\"spreadsheet\"])[24]")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.