How to find broken links using selenium webdriver and Images

Hi everyone welcomes back once again to Selenium webdriver tutorial. Today we are going to cover the very basic check that is a must in every application check. We will find broken links using selenium and how we can check what is the status of the same.


What is  find broken links using selenium

By the name itself, we can identify that we need to  find broken links using selenium it means we need to check the link which is pointing to wrong URL or invalid URL.


find broken links using selenium



I am sure you must have faced 404 page not found an issue in most of the application which is called broken link.

It does not only link you may also have to verify the images as well that we will see in the next tutorial.

While doing validation you only have to verify status

1- 200- Success- ok


Scenario for  find broken links using selenium

Before jumping to the code let’s take one simple example to get the actual concept.

Example1- Suppose we have one application which contains 400 links and we need to verify the link is broken or not.


Approach 1- 

Manual Process- Go to each link and verify the link is working or not.

Do you think it is the valid approach? No, it will take a full day to verify and you will not get the same efficiency and interest as well.


Approach 2-

Smart work- Write a code which will check all the link and will verify the status as well.

Since we all are smart so we will take Smart work and will see how to find broken links using selenium.

Before I start let me introduce HttpURLConnection class which will help us to verify the status of the response.


1- Selenium setup  should be completed


Refer complete video find  broken links using selenium


Program for find broken links using selenium




You can see we are getting 49 links and all seems OK.

Congrats 🙂

find broken links using selenium



I hope you can understand how easy and how important to verify the link and images. You can try the above program and let me know if any issue in above program.



  1. Sri Datta
  2. Vahe
  3. Gursimran singh
  4. Saurabh
  5. Vimal
  6. Vimal
  7. Vimal
  8. Aman
    • Aman
  9. bhaskar