How can I check broken links of website using ruby Selenium Web-driver ?

94 views
Skip to first unread message

Kousik Roy

unread,
Jul 15, 2014, 4:27:40 PM7/15/14
to seleni...@googlegroups.com
I want to find all the broken links from any web site.
What i want to do is-
1.Find all the url of a web site and thn
2.Run all the url to find bad or 404 page

Can any one help me ?

Thanks
Kousik

Rafael s

unread,
Dec 19, 2014, 8:20:55 AM12/19/14
to seleni...@googlegroups.com

Subodh Bakshi

unread,
Dec 22, 2014, 5:43:35 PM12/22/14
to seleni...@googlegroups.com
I have some experience in finding all broken footer links in Java. Maybe you can use the equivalent of the below snippet in ruby:

WebElement footer= driver.findElement(By.xpath("//div[@id='footer']"));  // Get Footer element which contains all footer links
  System.out.println(footer.findElements(By.tagName("a")).size()) ;
  List<WebElement> footlinks = footer.findElements(By.tagName("a"));
  int i = footer.findElements(By.tagName("a")).size(); //Get number of links
 
  for(int j = 0;j<i;j++){    //create loop based upon number of links to traverse all links 
   footer= driver.findElement(By.xpath("//div[@id='footer']"));   // We are re-creating "footer" webelement as DOM changes after navigate.back()
   footer.findElements(By.tagName("a")).get(j).getText();
   footer.findElements(By.tagName("a")).get(j).click();
      Thread.sleep(3000);
   System.out.println(driver.getTitle());
      if(driver.getTitle().contains("404")) {
       System.out.println("404 Found");
      }
      driver.navigate().back();
   Thread.sleep(4000);
  }

--
--
You received this message because you are subscribed to the Google Groups "selenium-ruby" group.
To post to this group, send email to seleni...@googlegroups.com
To unsubscribe from this group, send email to selenium-rub...@googlegroups.com
For Selenium-Ruby project, visit http://seleniumhq.org/projects/ruby/
For Selenium related questions like Core, Server, and RC client in other language, please go to http://clearspace.openqa.org/community/selenium
---
You received this message because you are subscribed to the Google Groups "selenium-ruby" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-rub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks and Regards,
Subodh Bakshi
551-574-2719
Reply all
Reply to author
Forward
0 new messages