TestStack / TestStack.Seleno

Seleno helps you write automated UI tests in the right way by implementing Page Objects and Page Components and by reading from and writing to web pages using strongly typed view models.
http://teststack.github.com/TestStack.Seleno/
MIT License
180 stars 60 forks source link

Feature request: Restrict WaitFor.AjaxCallsToComplete to a list of specific domains or URLs #209

Open isaldarriaga opened 9 years ago

isaldarriaga commented 9 years ago

In a website is very common to have asynchronous requests to external domains which are not critical to the website execution.

Live chat services, analytics, tracing repos, static content, etc. are commonly placed in external domains.

Sometimes those async request are fired periodically from the local domain for ping purposes, and they can affect tests if they are just waiting for all ajax requests to complete.

Imagine this scenario: Selenium instruct the browser to perform an action which is resolved via an ajax request. The test runner enters in a waiting cycle for all ajax to complete after that. A live chat window ping an external domain, so we have 2 requests scheduled for execution in the browser. The browser execute the ping request but defer the one we want. The first byte is received, the ping completed, so basically all running ajax completed. It's time for the test runner to evaluate all ajax completion, succeeds, exits, and the next sentence in the test is performed. The test fails.

Since the test runner, the driver and the browser run in isolated processes, other race conditions can occur in similar scenarios.

When waiting for ajax to complete I'm more interested on waiting for specific requests to the local domain, or external API domains, rather than just all requests. So it would be very useful either to restrict the WaitFor.AjaxCallsToComplete to the concrete list of domains hosting the services, or to the specific URL endpoints that I'm interested for the test.

Please vote.

robdmoore commented 9 years ago

Assuming that you aren't constantly firing ajax requests in parallel there should be a gap where no ajax is currently in flight and so the existing method will still work.

It's a fair point though.

Off the top of my head I don't know of the best way to implement it. The current check is very basic and I'm not sure of the best way to check based on domain: https://github.com/TestStack/TestStack.Seleno/blob/master/src/TestStack.Seleno/PageObjects/Actions/Wait.cs#L21

If you (or something else) can come up with a way to do it feel free to submit a PR.

Thanks