[英]How to access links in the specific section of links through selenium webdriver
你可以這樣做:
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();
}
根據您的需要自定義代碼。 它應該是這樣的:
//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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.