# VALIDATION

In the Scriptless Automation Framework, the `VALIDATION` field is essential for specifying the expected outcomes or values against which the state or properties of web elements are checked during automation tests. This field is effectively paired with `VALIDATION_TYPE` to enable various forms of validation checks.

**Role of the `VALIDATION` Field**

* **Purpose**: The `VALIDATION` field is used to define the expected result or benchmark for comparison during the validation of web elements.
* **Versatility**: Its usage varies depending on the chosen `VALIDATION_TYPE`, catering to a wide range of validation scenarios.

**Interaction with `VALIDATION_TYPE`**

The `VALIDATION_TYPE` dictates how the `VALIDATION` field is employed:

<details>

<summary><strong>EQUAL_IGNORE</strong></summary>

Compares the web element's text with the value in `VALIDATION`, ignoring case differences.

**Example:**

<pre><code><strong>PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
</strong>SwagLabs,NONE,NONE,pageTitle,NONE,NONE,Swag Labs,EQUAL_IGNORE
</code></pre>

**Tutorial:**

<https://youtu.be/X7RBAiojoeo>

</details>

<details>

<summary><strong>IS_DISPLAY</strong></summary>

This type does not utilize `VALIDATION`, focusing instead on the element's visibility.

**Example:**

```
PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
SwagLabs,NONE,NONE,pageTitle,NONE,NONE,NONE,IS_DISPLAY
```

**Tutorial:**

<https://youtu.be/SgxgHDhD2d4>

</details>

<details>

<summary><strong>IS_BUTTON_ENABLE</strong> / <strong>IS_BUTTON_DISABLE</strong></summary>

These types do not use `VALIDATION`, assessing the enablement or disablement of a button element.

Example:

```
PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
SwagLabs,NONE,NONE,loginButton,NONE,NONE,NONE,IS_BUTTON_ENABLE
SwagLabs,NONE,NONE,loginButton,NONE,NONE,NONE,IS_BUTTON_DISABLE
```

</details>

<details>

<summary><strong>ATTRIBUTE_VALUE_PRESENT</strong> / <strong>ATTRIBUTE_VALUE_NOT_PRESENT</strong></summary>

Here, `VALIDATION` specifies the attribute value to check for its presence or absence.

* Example for **ATTRIBUTE\_VALUE\_PRESENT**:

  ```
  PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
  SwagLabs,NONE,NONE,userName,NONE,Automation,NONE,NONE
  SwagLabs,NONE,NONE,userName,NONE,NONE,NONE,ATTRIBUTE_VALUE_PRESENT
  ```
* Example for **ATTRIBUTE\_VALUE\_NOT\_PRESENT**:

  ```
  PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
  SwagLabs,NONE,NONE,userName,NONE,NONE,NONE,ATTRIBUTE_VALUE_NOT_PRESENT
  ```

</details>

<details>

<summary><strong>ATTRIBUTE_EQUAL_IGNORE</strong></summary>

Compares an attribute's value against the `VALIDATION` field value, ignoring case. `VALIDATION` should follow the template `attributeExpected|attributeProperty`.

Example:

```
PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
SwagLabs,NONE,NONE,userName,NONE,NONE,form_input|class,ATTRIBUTE_EQUAL_IGNORE
```

DEMO -> <https://youtu.be/4YNpkKYCopI>

</details>

<details>

<summary><strong>ATTRIBUTE_EQUAL</strong></summary>

Compares an attribute's value against the `VALIDATION` field value. `VALIDATION` should follow the template `attributeExpected|attributeProperty`.

* Example:

  ```
  PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
  SwagLabs,NONE,NONE,userName,NONE,NONE,form_input|class,ATTRIBUTE_EQUAL
  ```

</details>

<details>

<summary><strong>ATTRIBUTE_CONTAINS</strong></summary>

Ensures the attribute's value contains the substring provided in the `VALIDATION` field.`VALIDATION` should follow the template `attributeExpected|attributeProperty`.

* Example:

  ```
  PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
  SwagLabs,NONE,NONE,userName,NONE,NONE,form_input|class,ATTRIBUTE_CONTAINS
  ```

</details>

<details>

<summary><strong>CUSTOM</strong></summary>

Custom validation logic may vary in its use of the `VALIDATION` field.

</details>

<details>

<summary><strong>CSS_PROPERTY</strong></summary>

Added a feature for validating CSS property types, enabling users to ensure UI components match expected CSS values accurately. `VALIDATION` should follow the template `"cssExpected | CssPropertyName"`.

* **Example:** To validate the font-family of a page title in SwagLabs, the syntax would be:

  Copy

  ```
  PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
  SwagLabs,NONE,NONE,pageTitle,NONE,NONE,"""DM Mono"", ""sans-serif""|font-family",CSS_PROPERTY
  ```

</details>

<details>

<summary><strong>PAGE_COMPARISON</strong></summary>

Validate the screenshot taken from the driver against the expected screenshot stored in directory `test_data/web/page_screenshot` .

```
PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
NONE,NONE,NONE,NONE,LOAD_URL,https://www.saucedemo.com/,NONE,NONE
SwagLabs,VISIBILITY,NONE,userName,SEND_KEYS,$text.firstName,NONE,NONE
SwagLabs,NONE,NONE,pageTitle,NONE,NONE,screenPage,PAGE_COMPARISON
```

</details>

<details>

<summary><strong>NOT_EQUALS</strong></summary>

Validate the element text is not equal to the expected text.

```
PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
NONE,NONE,NONE,NONE,LOAD_URL,https://www.saucedemo.com/,NONE,NONE
SwagLabs,NONE,NONE,pageTitle,NONE,NONE,Swag Lab,NOT_EQUALS
```

</details>

<details>

<summary><strong>IS_NOT_DISPLAY</strong></summary>

Validate the element is not visible on the HTML page.

<pre><code><strong>PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
</strong>NONE,NONE,NONE,NONE,LOAD_URL,https://www.saucedemo.com/,NONE,NONE
SwagLabs,NONE,NONE,pageTitle,NONE,NONE,NONE,IS_NOT_DISPLAY
</code></pre>

<https://youtu.be/MmlHqld809w>

</details>

<details>

<summary><strong>IS_ELEMENT_PRESENT</strong></summary>

Validate the element is present/display on the HTML page

```
PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
NONE,NONE,NONE,NONE,LOAD_URL,https://www.saucedemo.com/,NONE,NONE
SwagLabs,NONE,NONE,pageTitle,NONE,NONE,NONE,IS_ELEMENT_PRESENT
```

</details>

<details>

<summary><strong>IS_ELEMENT_NOT_PRESENT</strong></summary>

Validate the element is not present/display on the HTML page

<pre><code>PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
NONE,NONE,NONE,NONE,LOAD_URL,https://www.saucedemo.com/,NONE,NONE
SwagLabs,NONE,NONE,pageTitle,NONE,NONE,NONE,<a data-footnote-ref href="#user-content-fn-1">IS_ELEMENT_NOT_PRESENT</a>
</code></pre>

</details>

<details>

<summary><strong>NONE</strong></summary>

Indicates no validation is required, rendering the `VALIDATION` field unused.

</details>

**Example Scenarios**

* If `VALIDATION_TYPE` is `EQUAL_IGNORE` and `VALIDATION` is "Submit", the framework checks if the element’s text is "Submit", irrespective of case.
* For `IS_DISPLAY`, the `VALIDATION` field is not necessary; the framework simply confirms the element's presence.

[^1]: ValidationType


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.precisiontestautomation.in/scriptlessautomation/automation-platforms/scriptlessweb-automation/web-automation-key-phrases/validation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
