Using Asserts

What is an Assert?

An Assert is a Boolean expression that is added at a specific point in a test script to validate a condition which will be true unless there is a bug in the program. A test assertion is defined as an expression, which encapsulates some testable logic specified about a target under test.

Asserts in Sofy

To create an Assert, you should first start by Creating a Nocode automated test. To validate an Assert function, you should enable Assert mode.  You can do that by clicking the Assert icon in the Action Bar.

Enabling Assert using Sofy

Enabling Assert

When you enter the Assert mode, you will see be a RED icon at the top right of the UI. At this point you able to select any of the individual controls and create assertions to validate existence or non-existence of a control or Text.

Assert Enabled in Sofy

Below are the Assert validation Rules.

  1. To validate if a specific text (on a label or a button or any control) is an exact match, use [Equals Exact Match]. In this example, we are checking for SIGN IN button exists on the page.

    Assert Exact Match

  2. To validate if a specific text does not exist in the screen, use [Not Equals Exact match]. In the example below, we are validating the SIGN IN button does not appear.  An app might require that if the user is already signed in, there should not be a SIGN IN button.Assert Not Equals Exact Match Sofy
  3. To validate if an image (or icon) is exact or similar match. Exists Exact Match means the image has the same Resource ID, type and image. Exists Similar match here implies that source image exists in the vicinity of the original icon and not necessarily in the exact location. In the example below, we are validating if Search icon exists in the screen and looks exactly as the one below.

    Assert Exists Exact Match Sofy

  4. To validate if the CheckBox control is Checked or Unchecked [Checked] [Unchecked]. In the example, we are making sure that default state of the CheckBox is Checked.Assert Checked Sofy
  5. To validate a Text box value in a Test variable, use Test Variable Equals Exact Match. In the example below we are validating if the Text box has the same value as the Test data variable.
    Assert Test Data Variable
    Once an assert is created, you can see that the assert is recorded as part of the automation code.
    Assert Nocode Automation Sofy
1 2 3