in Selenium by
Q:
How can you find Broken Links in a page using Selenium WebDriver?

► Click here to show 1 Answer

0 votes
by
// To store the list

List <WebElement> eleList = driver.findElements(By.xpath("xpath"));

// To fetch the size of the list

int listSize = eleList.size();

//for loop

for (int i=0; i<listSize; i++)

{

// Clicking on each link

links.get(i).click();

// Navigating back to the previous page that stores the links

driver.navigate().back();

}

1

2

3

4

5

6

7

8

9

10

11

12

// To store the list

List <WebElement> eleList = driver.findElements(By.xpath("xpath"));

// To fetch the size of the list

int listSize = eleList.size();

//for loop

for (int i=0; i<listSize; i++)

{

 // Clicking on each link

 links.get(i).click();

 // Navigating back to the previous page that stores the links

 driver.navigate().back();

}
Selenium
Learn More with Madanswer

Related questions

0 votes
asked Aug 22, 2019 in Selenium by john ganales
...