Aug 22, 2019 in Selenium
Q: How can you find Broken Links in a page using Selenium WebDriver?

1 Answer

0 votes
Aug 22, 2019
// 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();

}
Click here to read more about Selenium
Click here to read more about Insurance

Related questions

0 votes
Aug 22, 2019 in Selenium
...