-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Added BrokenLinkChecker utility to verify broken links #15543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied review changes
|
I certainly don't speak for the project, but I would be inclined to reject this PR because it doesn't align with Selenium's goals and is also only implemented in one language binding. This looks like a useful feature, but it belongs in your test framework, not Selenium itself. |
|
Thank you, @OmkarGharat for this code suggestion. The support packages contain example code that many users find helpful, but they do not necessarily represent We actively encourage people to add the wrapper and helper code that makes sense for them to their own frameworks. |
User description
Contributing to Selenium!
Motivation and Context
In many Selenium projects, ensuring that the web application links are functioning properly is a common requirement. This change introduces a utility method to check whether a link is broken by sending an HTTP
HEADrequest, which helps avoid loading unnecessary data. The method uses the response code from the server to determine whether the link is working or broken (response code >= 400).This improvement will be useful for anyone automating tests and verifying the functionality of links on a webpage without needing to load the entire content of the target URL.
Types of changes
Checklist
This pull request introduces the
BrokenLinkCheckerclass with methods to verify whether a link is broken by using aHEADrequest instead of loading the entire content of the link. The class supports checking both individual web elements (WebElement) and URLs directly. TheisBroken()method handles both cases by checking thehrefattribute of a web element and sending aHEADrequest to the URL, and returns a boolean indicating if the link is broken (response code >= 400).PR Type
Enhancement, Tests
Description
Introduced
BrokenLinkCheckerutility class for link verification.Added
isBroken(WebElement)method to check links in web elements.Added
isBroken(String)method to validate URLs using HTTPHEADrequests.Handles invalid URLs and connection errors gracefully.
Changes walkthrough 📝
BrokenLinkChecker.java
Introduced `BrokenLinkChecker` utility class for link validationjava/src/org/openqa/selenium/support/BrokenLinkChecker.java
BrokenLinkCheckerutility class to check broken links.isBroken(WebElement)to validate links in web elements.isBroken(String)to validate URLs using HTTPHEADrequests.