Check broken links in an URL

Best practices, code snippets for common functionality, examples, and guidelines.
ndubs
Posts: 2
Joined: Tue Aug 16, 2016 3:58 am

Check broken links in an URL

Post by ndubs » Wed Aug 24, 2016 2:18 am

Hi,
I need to run a test to check if the links in a web page are broken. How do I do that with Ranorex?
For example: I'm running an automated test on ranorex main page. How do I check that the "Blog" and "Forum" links are not broken?
Thank you.
Natalie

Martin
Posts: 152
Joined: Fri Aug 15, 2014 12:24 pm

Re: Check broken links in an URL

Post by Martin » Wed Aug 24, 2016 8:55 am

Pick a web element for both the Blog and Forum that confirms that both websites are online and add them to repository.

Test case:
OpenBrowser (1 case: Forum, 2nd case: Blog)
Confirm that those 2 elements that you added to the repository exist.

ndubs
Posts: 2
Joined: Tue Aug 16, 2016 3:58 am

Re: Check broken links in an URL

Post by ndubs » Mon Aug 29, 2016 1:53 am

Is there a way for me to check for broken links without opening the links to check the element in it? The pages I need to check have hundreds of links in it (e.g. site map) so it will be impossible to open each link to check element existence.

Martin
Posts: 152
Joined: Fri Aug 15, 2014 12:24 pm

Re: Check broken links in an URL

Post by Martin » Mon Aug 29, 2016 7:15 am

Well there is some discussion about it here:

http://www.ranorex.com/forum/check-http ... t9803.html

But that specific implementation needs some further improvments (check the answer i posted there) through user code.

As Ranorex is based on .NET you can actually further the functionality through user code but this means some research and knowledge of either C# or VB.net. Furthermore, HTTP statuses are a tricky thing. You might get a correct header response but the site itself might not match your required test case. So your understanding of each state of your SUT must be fully analized beforehand.

Furthermore, if you acutally have to test website elements (such as menu elements and buttons + functionality) this implementation will loose all it's benefits as you aren't actually doing this.

Regards,
Martin