Friday, November 1, 2019

How do you identify broken links in Selenium Automation?

When we are asked to identify the broken links in the application, what we do? Collecting all the links on the page to a list and looping through links, clicking on links one by one and verify whether the content on the next page displayed or not?

This process is time consuming, and not that effective as it involves multiple to and fro actions. We can identify the broken links without clicking on the each link using Rest-assured (Java API Library). If you wish to know more about rest-assured click this link. Lets jump into coding part.

Search for "rest-assured maven dependency" in Google. Then copy the latest version of rest-assured dependency of "io.rest-assured" as shown in the below screenshot. Add it to your pom.xml file.



In Rest-assured, we have a Http method called "GET", this method is used for retrieving the information from the server. If the link is not broken the server sends response with status code 200 (OK), if the link is broken we receive it sends the status code 404 (Not Found). We use the same logic in our test case.


As shown in the above program, we get the status code of each link and we verify whether it is equal to 200 or not. If not 200, we the link is considered as broken link.

Check the result in the screenshot below


This is how we can identify the broken links using Rest-assured easily.

#HappyTesting #HappyLeaarning #qababu

11 comments:

  1. Replies
    1. I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts. Python Projects for Students Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account. Project Center in Chennai

      Delete
  2. It would not be fair if we compliment all the blog writings but not the author.
    Automation testing

    ReplyDelete
  3. Nice post. Useful information. This is always happy to know about Salesforce training in Gurgaon whose certification program helps many to get certificed. I strongly urge you to join now in Salesforce Training in Hyderabad | Course Price | Training institute and enroll for free demo at Salesforce Training in Bangalore | Course Certification Cost and Job Placement Assistance . I have gone through this Salesforce Certification Training. Why done you enroll for a free demo at Salesforce training institutes in Chennai [updated] | Course Price

    ReplyDelete
  4. Glad to chat your blog, I seem to be forward to more reliable articles and I think we all wish to thank so many good articles, blog to share with us. hire automation professional

    ReplyDelete
  5. This is one of the best content for this topic and this is very useful for me. Thank you!
    Unix Training in Chennai
    Linux Training in Chennai
    Linux Course in Chennai

    ReplyDelete

Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...