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.
-
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=141Phil Kirkham– Phil Kirkham2014年02月26日 16:23:31 +00:00Commented 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– Kousik Roy2014年02月26日 16:44:49 +00:00Commented 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?Phil Kirkham– Phil Kirkham2014年02月26日 18:39:32 +00:00Commented 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– Kousik Roy2014年02月27日 05:41:59 +00:00Commented Feb 27, 2014 at 5:41
1 Answer 1
You could use next algorithm
- Get all links from page.
- 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!
-
Thanks alex thanks for your answer.Can you give me an example of steps 1 and steps 2.Kousik Roy– Kousik Roy2014年02月27日 22:14:53 +00:00Commented 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="(.+?)"/)alexey.chumagin– alexey.chumagin2014年02月28日 14:44:25 +00:00Commented Feb 28, 2014 at 14:44
Explore related questions
See similar questions with these tags.