> For the complete documentation index, see [llms.txt](https://docs.precisiontestautomation.in/scriptlessautomation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.precisiontestautomation.in/scriptlessautomation/automation-platforms/scriptlessweb-automation/web-automation-template.md).

# Web Automation Template

#### Introduction

This document provides a comprehensive guide on using the Web Automation Template for streamlining web interactions. The template is structured to define and execute web automation steps in a systematic and efficient manner.

#### Template Structure

The template follows a structured format to outline the automation steps:

`PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE`

Each component of the template is explained below:

* **PAGE\_NAME**: Refers to the property file that contains web element locators. It is used to organize and reference the elements needed for automation steps on a specific page.
* **WAIT\_TYPE**: Defines the condition to wait for before performing an action, such as waiting for an element to be visible or a specific time delay.
* **SCROLL\_TYPE**: Indicates if scrolling is required on the page, and the type of scroll action needed.
* **ELEMENT\_NAME**: Names the web element that is the target of the action, such as a button, link, or input field.
* **ACTIONS**: Describes the action to be performed on the web element, like clicking, loading a URL, or sending keys.
* **SEND\_KEYS**: Details any text or keys to be sent to the web element, applicable in actions like form filling.
* **VALIDATION**: Outlines the expected result or output for validation after the action is performed.
* **VALIDATION\_TYPE**: Specifies the method of validation, like checking for equality, string contains, etc.

#### Example Use Case

Here are step-by-step examples using the template:

<table data-full-width="true"><thead><tr><th>PAGE_NAME</th><th>WAIT_TYPE</th><th>SCROLL_TYPE</th><th>ELEMENT_NAME</th><th>ACTIONS</th><th>SEND_KEYS</th><th>VALIDATION</th><th>VALIDATION_TYPE</th></tr></thead><tbody><tr><td>NONE</td><td>NONE</td><td>NONE</td><td>NONE</td><td>LOAD_URL</td><td><a href="https://www.saucedemo.com/">https://www.saucedemo.com/</a></td><td>NONE</td><td>NONE</td></tr><tr><td>SwagLabs</td><td>VISIBILITY</td><td>NONE</td><td>pageTitle</td><td>NONE</td><td>NONE</td><td>Swag Labs</td><td>EQUAL_IGNORE</td></tr></tbody></table>

**LOAD\_URL Action**

* Format: `PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE`
* Example: `NONE,NONE,NONE,NONE,LOAD_URL,https://www.saucedemo.com/,NONE,NONE`
* Description: This step involves loading the URL "<https://www.saucedemo.com/>" without any preconditions or validations.

**Page Title Validation**

* Format: `PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE`
* Example: `SwagLabs,VISIBILITY,NONE,pageTitle,NONE,NONE,Swag Labs,EQUAL_IGNORE`
* Description: This step waits for the visibility of the 'SwagLabs' page title and validates that it matches "Swag Labs".

#### Best Practices

* Always name your property files(PAGE\_NAME) and web elements(ELEMENT\_NAME) clearly and descriptively to ensure clarity in automation scripts.
* Accurately set WAIT\_TYPE to prevent flakiness due to timing issues.
* Implement VALIDATION steps to ensure each action achieves the expected outcome.

#### Troubleshooting

* **Problem**: Actions not executing as anticipated.
  * **Solution**: Check that the `ELEMENT_NAME` corresponds correctly to the locator in the `PAGE_NAME` property file and that `WAIT_TYPE` is set properly.
* **Problem**: Validation steps not passing.
  * **Solution**: Confirm that the expected result in `VALIDATION` matches the actual result and that `VALIDATION_TYPE` is appropriate for the test case.

### File

{% file src="/files/orlhoo0dOR8UxJhpd3RG" %}
