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 -
- Assertions for elements on a page
- 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:
|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:
|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:
|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"]:
|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:
|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:
|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.
|Title Should Be||Verify that the page title exactly matches the specified string|
2. Assertion on Page URLs:
|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:
|Page Should Not Contain||Verify that the specified string does not exist in the page|
4. Assertions on all HTML Elements on the Page:
|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