> For the complete documentation index, see [llms.txt](https://help.autify.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.autify.com/nocode-web/en/autify-university/advanced/assertions-1/assertion-elements-on-the-page.md). Agents can also search and read this documentation through its [MCP server](https://help.autify.com/~gitbook/mcp).

# Assertions on elements in a page

## 1. General assertions

The assertions in this section work on **any kind of HTML elements**.

### Visibility assertion

| Keyword                   | Description                               |
| ------------------------- | ----------------------------------------- |
| Element Should Be Visible | Verify that the target element is visible |

{% hint style="info" %}
**Tip**

This assertion will fail if the target element exists in the HTML code but is not visible due to `display: none;`, `visibility: hidden;` or `opacity: 0;`, or the target element is outside of viewport. See also the following FAQ: [What is the difference between "Page Should Contain Element" and "Element Should Be Visible"?](https://help.autify.com/nocode-web/en/faq/faq-create-scenario/faq-assertion/diff-between-should-contain-and-should-be-visible.md)
{% endhint %}

### Basic text assertions

| Keyword                            | Description                                                                                                                                        |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| 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                                                                        |
| Element text should start with     | Verify that the string of the target element starts with the specified string                                                                      |
| Element text should not start with | Verify that the string of the target element does not start with the specified string                                                              |
| Element text should not be empty   | Verify that the target element contains one or more non-space characters (Space characters include spaces, tabs, line breaks such as LF, CR, etc.) |

{% hint style="info" %}
**Tip**

This assertion will fail if the target element exists in the HTML code but is not visible due to `display: none;`, `visibility: hidden;` or `opacity: 0;`.
{% endhint %}

### Text assertions with RegExp

| Keyword                                  | Description                                                                      |
| ---------------------------------------- | -------------------------------------------------------------------------------- |
| Element text should match **RegExp**     | Verify that the string of the target element matches the given **RegExp**        |
| Element text should not match **RegExp** | Verify that the string of the target element does not match the given **RegExp** |

Using **RegExp**, you can create pretty flexible text assertions that fit your use case. Here are some RegExp ideas for your reference:

* **`^Good (morning|night)`**
  * Text that starts with `Good morning` or `Good night`
    * Matching examples: `Good night`, `Good morning, Hatty!`
* **`w[ow]+w$`**
  * Text that matches `w` followed by one or more `o` or `w` and ends with `w`
    * Matching examples: `wowow`, `Oh, wow`
* **`^\d{3}-\d{4}$`**
  * Text that starts with 3 consecutive digits followed by a hyphen and ends with 4 consecutive digits
    * Matching examples: `123-4567`, `999-0000`

For more information about its syntax, see [Regular expression syntax cheat sheet (MDN)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet)

{% hint style="warning" %}
**Note**

* Text assertions with RegExp will fail when the given RegExp contains any syntax error.
* Flags such as `i` (ignore casing) or `m` (multiline) are not supported.
  {% endhint %}

### Checkbox assertions

| Keyword                         | Description                                              |
| ------------------------------- | -------------------------------------------------------- |
| Checkbox Should Be Selected     | Verify that the checkbox or radio button is checked.     |
| Checkbox Should Not Be Selected | Verify that the checkbox or radio button is not checked. |

{% hint style="info" %}
**Tip**

Autify's ML-powered assertions on checkboxes work not only on `<input type="checkbox">` elements but also any elements that look like checkboxes, such as `<div>` and `<span>` elements disguised as checkboxes using styles!
{% endhint %}

### Number assertions

The following assertions are based on the numbers and ". (period)" . Specifically, assertions are made on the first digit (0 - 9) through all non-numeric characters (including commas) in the text. Thus, for example "$1,234", if the text contains ", (comma)", the assertion is made for 1 only.

| Keyword                       | Description                                            |
| ----------------------------- | ------------------------------------------------------ |
| Number should be greater than | Verify that the number is greater than the given value |
| Number should be smaller than | Verify that the number is smaller than the given value |

{% hint style="warning" %}
**Note**

Number assertions will fail when the target is not a number.
{% endhint %}

### Class assertions

| Keyword                              | Description                                                   |
| ------------------------------------ | ------------------------------------------------------------- |
| Element classname should contain     | Verify that the element contains the given class name         |
| Element classname should not contain | Verify that the element does not contain the given class name |

Class names are detected by partial matching. For example, if you specify `state-1` for the class name, it matches with the following:

* `<div class="state-10">`
* `<div class="sample-a state-1">`

One of the use cases of this assertion can be to verify the presence or absence of a class to which a particular style is applied.

## 2. Interactivity assertions

The following assertions work on `BUTTON`, `INPUT`, `SELECT`, `TEXTAREA`, `OPTGROUP`, `OPTION`, and `FIELDSET`.

| Keyword                    | Description                                                                                                |
| -------------------------- | ---------------------------------------------------------------------------------------------------------- |
| Element Should Be Enabled  | Verify that the element is interactable (Checks if the element **has not disabled or readonly** attribute) |
| Element Should Be Disabled | Verify that the element is not interactable (Checks if the element **has disabled or readonly** attribute) |

{% hint style="warning" %}
**Note**

Even if the element looks like a `<button>` or a `<select>` element, these commands will not be shown if it is actually implemented as a different element decorated by CSS. And also, Elements that don’t have a disabled attribute but cannot be operated with JavaScript are considered to be enabled.
{% endhint %}

## 3. Form element assertions

### Input assertions

The following assertions work on `INPUT` elements.

| 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        |

### Textarea assertions

The following assertions work on `TEXTAREA` elements.

| 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        |

### Pull-down menu assertions

The following assertions work on `SELECT` elements. `SELECT` elements let users choose an option from multiple options, and they are often referred to as a drop-down list, pull-down menu, list box, etc.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-3782225a514c9e944dc6b16131134068313f6272%2Fzndsk-listbox.png?alt=media)

| 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 that this may not work well when multiple options are selected, and it will be supported in the future.

### Tips for pull-down menu assertions

If the default option 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.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-dfd87972d520541aa26e0b7bc863515759c91d5e%2Fzndsk-Screen_Shot_2021-05-01_at_9.55.06.png?alt=media)

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.

![](https://1964297753-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVdZPTgwISYb3LhjgKnw6%2Fuploads%2Fgit-blob-f128d80d85c5c7f4c77d695473ad7386e2e3b337%2Fzndsk-Screen_Shot_2021-05-01_at_9.47.56.png?alt=media)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.autify.com/nocode-web/en/autify-university/advanced/assertions-1/assertion-elements-on-the-page.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
