views:

51

answers:

1

The task is to check broken links on a webpage using selenium RC and java . It can be done simply by

a) click on link A
b) wait for page to open
c) focus on this window
d) verify text present on this page
e) Close this window

Then follow steps a to e for links B , links C .... links N

This process is sequential.

Is it possible to parallely open all links in new windows and verify whether they are broken or not i.e. a more professional way ?

Kindly Advice ( if possible with a sample of code )

A: 

Since a browser can realistically only click one link at a time, that's all you'll be able to do with Selenium. All it's doing is manipulating the browser as a user might.

If you're not concerned with AJAX at all, your better bet is probably to do this outside of Selenium with HTTPClient. There you could fetch the source and all links and issue a HEAD request to see if you get a 404 (no need to assert text is present). You could do this in parallel and not need to wait for the browser at all.

nirvdrum
Agreed. You should grab any opportunity you get to run tests without needing any user interface, and checking for broken links is perfect for that. Just crawl the page, extract the links, open each in an HTTP stream, verify the content. Repeat.This is also pretty easy to parallelize with TestNG, by the way (hint: once you have collected all the links, put them in a data provider and run it in parallel).
Cedric Beust