The basics of assertions
How to add an assertion step
You can add assertions by clicking the checkbox icon during recording.
There are two main types of assertions, and the way to add them differs as follows:
- Assertions for elements in a page
- Assertions for a page
To add an assertion for an element on a page, click the checkbox icon, mouse over the element on the page, and click on any grayed-out element you want to validate to see a list of assertion commands.
Select the appropriate command and click the Add button.
The assertion commands 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 commands.
Select the appropriate command and click the Add button. This will add the assertion step.
How to add operation steps such as "click" and "input text"
Operations such as "click" and "input text" will be automatically recorded as steps without any special attention when recording is enabled (red circle of Autify Recorder is blinking).
In all cases, the following verifications are required before performing the operation.
- The target element must exist.
The target element must be in a state where it can be manipulated. - Therefore, before clicking or entering text
Therefore, there is no need to add assertions to confirm that the element exists or is displayed before clicking or entering text.
Validation of SPA and other pages with asynchronous communication
All Autify assertions are designed to keep searching for a certain amount of time if the target element is not present on the page. Therefore, even if a page has asynchronous communication, it can be verified within a certain period of time without using [Sleep step].
By default, the time to continue the search is set to 30 seconds.
If you find that this process often takes more than 30 seconds, please contact our support team.
If only a few pages or processes take more than 30 seconds, please insert a wait step before the validation step to extend the wait time.
Index
The following is a list of assertion commands provided by Autify.
Each command is explained in the following sections.
- C
- E
- L
- P
- T
Assertions on elements in a page
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 |
For more details on Element Should Be Visible, please refer to this section.
For BUTTON, INPUT, SELECT, TEXTAREA, OPTGROUP, OPTION, FIELDSET:
Keyword | Description |
---|---|
Element Should Be Enabled | Verify that the element is interactable |
Element Should Be Disabled | Verify that the element is not interactable |
Even if the element looks like a <button> or a <select> element, these commands will not be displayed if it is actually written as a <div> or a <span>, and CSS is used to adjust its appearance.
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 |
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. |
Even if it looks like a checkbox, if it is actually written as a <div> or <span> and CSS is used to adjust its appearance, these commands will not be displayed.
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 |
For SELECT:
An element for selecting from multiple options, which can be called a drop-down list, pull-down menu, list box, etc.
* This may not work well when multiple options are selected, and it will be supported in the future.
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. |
If the default choice is selected for an element in a selection, it cannot be verified by List Should Have No Selections.
For example, the following screenshot shows a pulldown included in the form to request a demo of Autify, where the Company Size is displayed at the top, is not a No Selections state, but the option Company Size is selected.
If you want to check if the default choices are selected, use the "List Selection Should Be" option instead of the "List Should Have No Selections" option.
Assertions against the page
Assertions on page 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.
Keyword | Description |
---|---|
Title Should Be | Verify that the page title exactly matches the specified string |
If you need a partial match command for a title, please contact our support team.
Assertions 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.
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 |
Assertions on all HTML elements on the page
Currently, Page Should Contain Element is shown as a command for assertions on the page (click the "Assert against page" button), but in the future, it will be a command for assertions on elements within 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. For more information, please refer to this section.
Frequently Asked Questions about Assertions
What is the difference between "Page Should Contain Element" and "Element Should Be Visible"?
"Page Should Contain Element" succeeds if the target element is present in the HTML code.
Whether the element is visible or not doesn't affect the result: success or failure.
Note that it succeeds even if the element is not visible on the page, if it is invisible, or if it exists on the negative coordinate.
"Element Should Be Visible" succeeds if the target element is visible and exists.
It will fail if the element is not visible, such as display: none or hidden, even if it is present in the HTML code.
Both commands can be set to a wide range of values.
For example, if you want to see a particular form after performing a particular operation, you can select the entire form and use one of the above commands to confirm the purpose of the operation.
However, this command only checks whether the element exists and whether it is visible.
It cannot be used to check if all elements in the area are correct.
If you need to check the correctness of the displayed content, please set a separate command for each element.
Is it possible to check that the specified element does not exist?
If the element you want to check does not exist contains a string, you can use "Page Should Not Contain" or "Element Should Not Contain".
"Page Should Not Contain"
will check the entire page to make sure that no specific text is present, and
"Element Should Not Contain"
checks for the presence of a specific string within a specific element.
For example, if you are logged in with an administrator account and you want to see the string ADMIN that indicates that you are an administrator, but you are logged in with a regular user account and you don't want this string to appear on the page at all, you can use "Page Should Not Contain".
If you want to make sure that a particular string does not appear in a particular element, such as in a form or on a menu bar, you can use "Element Should Not Contain".
If you want to make sure that text is not present in an element that does not contain text or is difficult to determine by text, please contact our support team.
Is it possible to verify that a radio button is selected?
We do not have a standard assertion command for radio buttons implemented with INPUT[TYPE="RADIO"], but you can use the [JS Step] for this purpose. Please use the snippet to check if the element is checked or not.