Conditional Goto

The Conditional Goto TestStep

The Conditional Goto TestStep holds an arbitrary number of XPath expressions each together with a corresponding target TestStep. These are applied to the nearest Response of a previous Sampler TestStep; the configured XPath expressions are applied top-to-bottom and when an XPath expression evaluates to true the Conditional Goto will transfer execution to the specified TestStep.

Adding and opening a Conditional Goto TestStep shows the following editor:

Conditional Goto Configuration Dialog

This is rather straight-forward; the list to the top-left contains the defined conditions (empty for now, the editor to the right allows editing of conditions after they have been created, and the log at the bottom helps us test around a bit. Lets dive right in; select the Add button to the top left and Enter some name;

Add Condition

Press OK and then select the XPath wizard in the bottom right (only in the Pro version, be sure to have a response available), this allows us to select the node we want to check;

select path for condition

Here the nearest previous Sampler TestStep was a JDBC Request, we can see the generated XML presented in a tree view allowing us to easily select the node we want to use for our condition. After selecting it and pressing OK we get the following:

configured condition

The generated XPath is hightlighted on the top, at the bottom we now have to choose to which step the TestCase should jump if the XPath expression evaluates to true (which it doesn't for now, we need to surround the above generated XPath with an exists( ... ) clause to check for the existence of the specified element).

Now if we run the Conditional Goto with the top toolbar button we get:

test conditional goto

The log shows that our condition was successfully triggered.

Now we can add more conditions with different conditions and branching, allowing us to route TestCase execution as desired.