Assertions
  • 09 Nov 2021
  • 3 Minutes to read
  • Contributors
  • Dark
    Light

Assertions

  • Dark
    Light

Assertions Make Autify Go Round


Assertions are how you validate a specific element on the page. There are many assertions you can make each with their own specific purpose. Let's take a look at how and when to use each assertion.

How to make an assertion:

You can add assertions by clicking the checkbox button on the recorder during recording.

There are two main types of assertions that can be made -

  1. Assertions for elements on a page
  2. Assertions against a full page


To add an assertion for an element on the page, click the checkbox icon and mouse over the element you want to assert against. The element will be highlighted with a dark grey rectangle to indicate what element you want to assert. Click on it and a list of options will show up that you can choose from.

Select the appropriate option and click the "save assertion" button.

The assertion options displayed will vary depending on the target element.


To make an assertion for an entire page, click the checkbox icon and then click the "Assert against page" button, which will display a list of assertion options.

Select the appropriate option and click the "save assertion" button. This will add the assertion step.


Assertion's for Elements on a Page

1. For All HTML elements on the page:

Keyword Description
Element Should Be Visible Verify that the target element is visible
Element Text Should Be Verify that the string of the target element exactly matches the specified string
Element Should Contain Verify that the target element contains the specified string
Element Should Not Contain Verify that the element does not contain the specified string of characters


2. For Buttons, Input, Select, Textarea, Optgroup, Options, Fieldset:

Keyword Description
Element Should Be Enabled Verify that the element is interactable
Element Shoud Be Disabled Verify that the element is not interactable

Note: Even if the element looks like a "button" or a "select" element, these options will not be displayed if it is actually written as a div or span and CSS is used to adjust it appearance.


3. For Input:

Keyword Description
Textfield Value Should Be Verify that the content entered in the text field exactly matches the specified string
Textfield Should Contain Verify that the content entered in the text field contains the specified string


4. For Input[Type="Checkbox"]:

Keyword Description
Checkbox Should Be Selected Verify that the checkbox is checked
Checkbox Should Not Be Selected Verify that the checkbox is not checked

Note: Even if it looks like a checkbox, if the element actually is written as a div or span and CSS is used to adjust its appearance, the above options will not be displayed.

5. For TextArea:

Keyword Description
Textarea Value Should Be Verify that the content entered in the text area exactly matches the specified string
Textarea Should Contain Verify that the content entered in the text area contains the specified string


6. For Select:

Keyword Description
List Selection Should Be Verify that the option that match the specified string is selected
List Should Have No Selections Verify that nothing is selected with select with "multiple" attribute

Note: If the default choice is selected for an element in a selection, it cannot be verified by List Should Have No Selections.


Assertions for a Full Page

1. Assertions on Pages Titles:

A page title is a string of characters set in the title tag. It is displayed in tabs and window sections and is used as a name when bookmarking.

Screen Shot 2021-09-29 at 5.48.01 PM

Keyword Description
Title Should Be Verify that the page title exactly matches the specified string


2. Assertion on Page URLs:

Keyword Description
Location Should Be Verify that the current URL exactly matches the specified string
Location Should Contain Verify that the current URL contains the specified string

If you want to validate the URL of a page where the URL changes dynamically, we recommend using Location Should Contain.

3. Assertions on all Text Contained in the Page:

Keyword Description
Page Should Not Contain Verify that the specified string does not exist in the page


4. Assertions on all HTML Elements on the Page:

Keyword Description
Page Should Contain Element Verify that certain elements are present on the page

Even if the element is not visible to the general public, it will be considered successful if it exists as an HTML element.


Next Section: Hover Step


What's Next
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.