Generative AI-Based Testing Certification
Conditional Sequences
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
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
if exists
is if
with a validation attached. For example:click "ok" if page contains "Are you sure you want to delete?"
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.
if page contains "bla" then
click "element"
wait 10 sec
enter "some text" into "some other element"
end
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
if/else
clause. 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
if page contains "bla" then
check for some words
open the main menu
clear all
end
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.