Its purpose is to guard that the interaction of the user will/will not raise specific request to the server. It differs between following types:
- No Request
- AJAX Request
- HTTP Request (regular HTTP)
Request guards are available in Graphene Utility Class:
|If the given request isn't detected, the RequestGuardException is thrown.|
Guards are able to intercept the given object to verify, that request which occurs after a method invocation is expected.
Note that the request needs to end within the waiting period. If the request is finished before waiting period then guard stops waiting and test execution proceeds.
On the other hand when request has not been ended within waiting period the exception is thrown.
Let's examine following scenarios. GuardA means guard on controlA, GuardB means guard on controlB. XhrA is an ajax request triggered by controlA, XhrB is an ajax request triggered by controlB.
In this scenario XHR has started within waiting period but took long time to finish (slow Internet connection or request execution on server).
In this case RequestGuardException will be thrown.
Here we have interference of some other request (i.e. page is polling the server). We guard request that should be triggered by controlA but during waiting period some other XHR request ends.
Currently guards do not have any way to tell which operation did the request originated from, so the guard will stop waiting and text execution will proceed.
If in next step you want to i.e. click on button that would be rendered by XhrA (that hasn't yet finished) you would get ElementNotFoundException.
Currently there is no way to protect against this scenario.
|XHR may be triggered on slightly different event then the one fired by command (i.e. sendKeys does not trigger onchange)|