> 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/page_object_locators.md).

# page\_object\_locators

### Introduction

This guide provides detailed instructions on how to set up and use page object locators for web automation in Scriptless Automation. It includes the structure for storing locators, how to define them, and how to use them in web templates.

### Directory Structure

The locators for web pages should be stored in a dedicated directory within your test data folder. The recommended structure is as follows:

```
project
   └── test_data
       └── web
           └── page_object_locators
               └── gmail.properties
```

### Defining Locators

Locators should be defined in properties files. Each property represents a locator with its unique identifier and the type of selector used.

Locator syntax should be follow as below

```
elementName = SelectorType -> selector
```

#### **Example: `gmail.properties`**

```properties
# Locator definitions for Gmail
email = XPATH -> //*[@id="identifierId"]
```

In this example:

* `email` is the name of the element i.e. `elementName`.
* `XPATH` is the type of selector used to locate the element i.e. `selectorType`.
* `//*[@id="identifierId"]` is the actual XPath expression to locate the element i.e. `selector`.
* `elementName` and `SelectorType` define another locator with a generic name and type.

### Using Locators in Web Templates

Web templates use these locators to perform actions on the web elements. Each action is defined in a CSV file that specifies the page name, wait type, scroll type, element name, action to be performed, value to be sent, validation, and validation type.

#### **Example: Web Template**

```csv
csvCopy codePAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
gmail,NONE,NONE,NONE,LOAD_URL,https://www.gmail.com/,NONE,NONE
gmail,VISIBILITY,NONE,email,SEND_KEYS,john depth,NONE,NONE
```

In this example:

* The first row loads the Gmail URL.
* The second row waits for the visibility of the `email` element and then sends the text `john depth` to it.

### Supported Selector Types

The following types of selectors are supported:

* `ID`: Selects elements based on their unique ID attribute.
* `NAME`: Selects elements based on their name attribute.
* `CLASS_NAME`: Selects elements based on their class attribute.
* `TAG_NAME`: Selects elements based on their tag name.
* `LINK_TEXT`: Selects anchor elements with the exact visible text.
* `PARTIAL_LINK_TEXT`: Selects anchor elements containing the specified partial text.
* `XPATH`: Selects elements using XPath expressions.
* `CSS`: Selects elements using CSS selectors.

<br>
