This blog is for Automation Test Engineers

Sunday, 27 August 2017

How to fetch all links

Webdriver driver=new FirefoxDriver();

driver.get("https://www.flipkart.com/");
List<WebElement>alllinks=driver.findElements(By.xpath("//a"));
int linkcount=alllinks.size();

for(int i=0;i<alllinks.size();i++){
String linkname=alllinks.get(i).getText();
System.out.println(linkname);
}


0

0 comments:

Post a Comment