我必须计算存在于div中的li元素的数量。 下面是网页的HTML部分: enter image description here计算硒中“li”元素的数量
我已经写了下面的代码行数地砖:
public void configButtonCount()
{
WebElement button= driver.findElement(By.className(".config-category"));
List<WebElement> buttonCount = button.findElements(By.xpath("//li"));
System.out.println("List size is: " +buttonCount.size());
}
谁能告诉我,为什么它被显示为“无法找到元素:..config-category“? 另外,正确的代码行?
还为该div另一个类 - NG-范围。既可以使用这两个类,也可以使用css等。另外,// li xpath需要在它前面有一个点,否则它将返回所有的li而不是div中的那些... – Grasshopper