06 August 2007 - 1.7.5 |
Conditional Goto steps evaluate an arbitrary number of xpath conditions on the previous requests response message and transfer TestCase execution to the TestStep associated with the first condition that evaluates to true. This allows for conditional TestCase execution paths, where the result of some request controls how to move on in the TestCase. If no condition matches the current response, TestCase execution continues after the Goto Step as normal.
Sample scenarios could be:
Conditions use the same Saxon XPath engine as described for the XPath Assertion, remember that a condition must evaluate to a Boolean value to be valid (see examples below)
The ConditionalGoto Editor is opened by double clicking a ConditionalGoto test step either in the navigator or in the TestCase Editors' test-step-list.
The editor contains a list of configured conditions to the left, selecting an existing condition in the list will display that condition's expression and a target TestStep ComboBox to the right. The Test Condition button will evaluate the current condition against the current response and display the result (a response message must be available for the preceding TestRequest).
soapUI Pro adds an XPath Selector button to the right of the Test Condition button for easily selecting the XPath that should be used for evaluation.
The following actions are available from the bottom toolbar
Conditions must evaluate to a Boolean value, for example the following expression checks that there are hits in the search result returned from the Amazon web service:
declare namespace SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'; declare namespace ns1='http://webservices.amazon.com/AWSECommerceService/2005-10-05'; declare namespace SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'; count(//ns1:Item)>0
A generic condition that checks for a soap body would be:
declare namespace SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'; count(//SOAP-ENV:Body)=1
and the corresponding check for a soap fault would be:
declare namespace SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'; count(//SOAP-ENV:Fault)=1