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:
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
Example: gmail.properties
gmail.properties
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
andSelectorType
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
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 textjohn 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.
Last updated
Was this helpful?