Skip to main content

Posts

Showing posts from 2017

Broken Link Checker using Java & Selenium

We often come across the requirement to validate the links (i.e. Checking Broken links) in the web pages. Performing this task manually is tedious as there might be high number of links in your web page. Generally to validated it we depend on the third party websites where there might be confidentiality issues. Below is the code snippet which can be used locally & quickly to check the links without compromising on confidentially.

import com.jayway.restassured.RestAssured; import com.jayway.restassured.config.RedirectConfig; import com.jayway.restassured.config.SSLConfig; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.Test; import java.util.List; public class LinkChecker { WebDriver driver = null; public void validateLinksInPage() { List<WebElement> anchorTagsList = driver.findElements(By.ta…