< Previous | Front page | Next >
Skip to end of metadata
Go to start of metadata

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)

Basic Usage

Request guards are available in Graphene Utility Class:

If the given request isn't detected, the RequestGuardException is thrown.

Use cases

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.

Scenario 1

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.

Scenario 2

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.

Request start (thus end) may be delayed (i.e. by some javascript like a4j:queue) and request may not end within wait period. To deal with that you should increase wait period.
XHR may be triggered on slightly different event then the one fired by command (i.e. sendKeys does not trigger onchange)
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.