Conditional Sequences

Conditional Sequences Overview

Though test cases need to maintain a certain level of predictability, there will always be situations when a testing scenario presents variations. testRigor offers users ample ways to deal with these variations.

if exists

The first way testRigor allows users to handle variations is with the keyword if exists.
click "ok" if exists

This tells testRigor to perform the click if the element is on the screen; however, the test case will not fail if the element is not present.

*Note: if exists works with any command except for validations.

It is important to note that the wait timeout (the time it spends searching the page to see if the condition is true or false) for conditional commands is different from the wait timeout for everything else. The default timeout for conditionals is 3 seconds, but this can be modified by a setting in Settings -> Speed Optimizations.

if + validation

An extension of the keyword if exists is if with a validation attached. For example:
click "ok" if page contains "Are you sure you want to delete?"
This works with any validation. Here are some other examples.
grab value from "myDiv" if "myDiv" contains "Name"
drag "itemA" to "itemB" if "itemA" is on the right of "itemB"
fail with "Incorrect color" if property "color" of "myText" is not equal to "rgba(0,0,0,1)"

testRigor will notify you if the conditional statement was true or false. To see the notification, click More details...below the the screenshot where the step appears then click Show extra info.

if/else

In addition to inline conditionals, which provide a quick way to execute a command or a rule depending on the result of a validation, we also provide conditional blocks to allow you to test multiple conditions with multiple commands and/or rules.

You can execute multiple commands on one condition. For example:
if page contains "bla" then
  click "element"
  wait 10 sec
  enter "some text" into "some other element"
end
Also if you add an else clause you could execute other commands when the condition is not met. For example:
if page contains "bla" then
  click "element"
  wait 10 sec
else
  enter "some text" into "search"
  wait 10 sec
end
Test as many conditions as you want using the if/elseclause. For example:
if page contains "bla" then
  click "element"
  wait 10 sec
else if page contains "search" then
  enter "some text" into "search"
  wait 10 sec
else if page contains "foo" then
  enter "foo bar" into "element"
  wait 10 sec
  click "some button"
else
  wait 10 sec
  logout
end
In addition to commands you can execute rules inside the conditional blocks. For example:
if page contains "bla" then
  check for some words
  open the main menu
  clear all
end
Conditional blocks are very flexible cause you can mix commands and rules on every condition. For example:
if page contains "Welcome" then
  accept all cookies
  wait 20 sec
  open the main menu
else if page contains "Search" then
  click "Search"
  enter "Big TV's"
  purchase the first item on the list
else
  login
end

NOTE: Conditional blocks cannot be nested, we suggest you to use rules to nest complex conditions.

Auto-apply rules

Auto-apply rules are also sequences that run conditionally. See more here.

Test your knowledge

(a) 1 seconds
(b) 3 seconds
(c) 10 seconds
(d) 30 seconds

There is no way to tell if the precondition was true or false.
If the test cases passes, the precondition was true.
If the test cases fails, the precondition was false.
testRigor tells you in the More details... section below the screenshot where the conditional step appears

[wpcode id=”1112380″ answers=”2;4″ page=”Conditional Sequences” numoffields=”2″]