1

Now, I'm thinking for creating Web Automatic Testing Tool by using Selenium WebDriver with Visual Studio (C# ASP.Net).

When I create test cases, I have to make correct 'a' link's ID so that the tool can click defined links.

However, I'd like to make it automatic process, like clicking any 'a' link on the rendered page randomly for 5 minutes, for example. That means the tool will render pages until it finds any broken link.

Is it possible??

Jay
  • 1,170
  • 1
  • 11
  • 34
  • 1
    Will [this](http://stackoverflow.com/questions/28786474/how-to-perform-feasible-web-smoke-test-with-selenium-webdriver) help? – Saifur Mar 17 '15 at 13:41

1 Answers1

3

This would be possible using the page object framework as long as your links had something in common to be able to identify them.

You could Initialise the page when you first land on it and possibly use xPath selector to identify all links and put it into a List e.g.

[FindsBy(How = How.xPath, Using = "xpathToIdentifyAllLinks"]
public IList<IWebElement> Links { get; set; }

Since you have a common way to find links all you need to do is randomly select something from the Links list and click it. Then Reinitialize the page and do the same until an exception gets thrown?

The massive downside to this is if you end up with an exception getting thrown that the link is broken it will be hard to reproduce without any custom logging in place since you wont know what your test is doing.

Jamie Rees
  • 7,973
  • 2
  • 45
  • 83
  • The test would be for just like smoke test to see if there is any broken links or page error. How can I set the process time?? – Jay Mar 17 '15 at 13:49
  • What do you mean by process time? How long the test would run? You could use the MaxTimeAttribute if you are using NUnit (http://nunit.org/index.php?p=maxtime&r=2.6.3), but that would mean the test always will fail. Or you could put some code around it to loop for x amount of times then end the loop. – Jamie Rees Mar 17 '15 at 13:55
  • Oh~ yes. that was what I wanted. Thanks! – Jay Mar 17 '15 at 14:00
  • Glad to help! :) Any questions regarding this implementation please feel free to ask, I can try my best to help. – Jamie Rees Mar 17 '15 at 14:03
  • Jamie, I don't know how to use '[FindsBy(How = How.xPath, Using = "xpathToIdentifyAllLinks"]' this part. Could you show me an example?? – Jay Mar 17 '15 at 15:24
  • Take a look at this: http://stackoverflow.com/questions/8149808/whats-the-best-way-to-use-selenium-pageobject-design-pattern – Jamie Rees Mar 17 '15 at 16:22
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/73183/discussion-between-jamie-rees-and-jay). – Jamie Rees Mar 17 '15 at 16:30