How to verify dead links on page with Ruby Webdriver

24 views
Skip to first unread message

cat

unread,
Jun 1, 2017, 8:46:46 PM6/1/17
to webdriver
Hello,

I would like to check if there are dead links on my webpage, using Ruby/Webdriver/Rspec

thanks
C

darrell grainger

unread,
Jun 2, 2017, 8:56:10 AM6/2/17
to webdriver
Trying to use Selenium to check a page for dead links isn't a great idea. You will be essentially re-inventing existing tools. Additionally, you will probably do it wrong. There are numerous ways to create a link on a web page. If you code this in Selenium then you care going to have to find all the ways someone might have created a link. The obvious <a href="..."> will be easy to find. But what about web elements which have an onclick attribute? Or you can create web elements with callbacks. So clicking the web element will execute a, seemingly, unrelated javascript function. Then there are input web elements... just have a look at the POST REPLY button on this page.

The things you will have to code in order to find all the possible links will require you to REALLY understand how HTML, Javascript, etc. work. You can use command line tools like wget to scan an entire website for broken links. I'm sure there are more user-friendly tools out there as well.
Reply all
Reply to author
Forward
0 new messages