简体   繁体   English

在Selenium WebDriver(Java)中查找嵌套元素

[英]Find nested elements in selenium webdriver (Java)

I want to select several elements on a site and iterate through them. 我想选择站点上的几个元素并对其进行遍历。 Of these elements I want to find nested elements with xpath. 在这些元素中,我想找到带有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. 我的问题是xpath似乎不在we-element内搜索,而是从文档的根目录搜索。 What can I do? 我能做什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM