1

What is the most convenient way of using Ruby script for Selenium WebDriver to check all url's (from navigation menu)of any web page.Actually want to run them to see where they go.

For example:

Take - www.google.com and see if it goes to www.google.com (no error/redircts) or if i click to contact from the navigation menu then is it redirecting to the write page(google.com/contact) or throws a error such as 404, & 500.

4
  • Are you wanting to check response codes? If so, then with webdriver you cant - does this page answer your question? code.google.com/p/selenium/issues/detail?id=141 Commented Feb 26, 2014 at 16:23
  • No i do not want to check response of code.I just want to check the url's.
    – Kousik Roy
    Commented Feb 26, 2014 at 16:44
  • what do you mean 'check the urls'? If you want to check 'www.checkthis.com' and it does not exist what are you expecting? what exactly are you trying to test/check? Commented Feb 26, 2014 at 18:39
  • For example-I want to browse this site w3schools.com and want to check all the links in the left side bar. If I click to “Learn HTML5”link and if it returns me 404 or 500 error message then a report will generate as –page not found and result will be marked as fail. Point is i want to do this ruby script which will support selenium web driver.
    – Kousik Roy
    Commented Feb 27, 2014 at 5:41

1 Answer 1

3

You could use next algorithm

  1. Get all links from page.
  2. Implement ruby script to check all links

First steps are implemented in two ways

  • Open page by webdriver, and get all links by tag , for example
  • Get page by http request and parse html code by regex

Second step:

Implement script for request sending

Use this link for implemention script.

Good luck!

2
  • Thanks alex thanks for your answer.Can you give me an example of steps 1 and steps 2.
    – Kousik Roy
    Commented Feb 27, 2014 at 22:14
  • Get all links from page base_url = 'w3schools.com' url = URI.parse(base_url) req = Net::HTTP::Get.new(url.path) res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) } answer = res.body links = answer.scan(/<a.+?href="(.+?)"/) Commented Feb 28, 2014 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.