Basic Scripting in Squish (if else condition)

Last edited on

Verifying and Reporting using an if else condition

Below is an example that shows a simple if-else statement, and also two of Squish's test functions ( test.pass() and test.fail() ). Of course, Squish provides many other useful test functions.

Python

# Get a reference to an object of interest
button = waitForObject(names.Confirm_Button)
# Check whether the text is what's expected
if button.text == "OK":
    test.passes("Correct button text") # 'pass' is reserved in Python
else:
    test.fail("Incorrect button text: '%s'" % button.text)

JavaScript

// Get a reference to an object of interest
var button = waitForObject(names.Confirm_Button);
// Check whether the text is what's expected
if (button.text == "OK") {
    test.pass("Correct button text");
} else {
    test.fail("Incorrect button text '" + button.text + "'");
}