答案 0 :(得分:1)
您可以这样做:
List <WebElement> we = driver.findElements(By.xpath("//h3[text()='Quick Links ofHyderabad']/following::ul/a"));
int noOfLinks = we.size();
// To click on all the links just use a `for` loop
for(WebElement w : we) {
w.click();
}
答案 1 :(得分:0)
根据需要自定义代码。它应该是这样的:
//Pick all div elements:
List< IWebElement > elements = driver.FindElements(By.XPath(//div[contains(@class, 'description')]/h3));
// Now use a forloop to go through each element and grab the data you need.
String Data = elements.getText();
// Split the Data using regex and get the count as per your html code