👨💼ELEMENT_NAME
Definition of ELEMENT_NAME
ELEMENT_NAME
is a key component in web automation scripts that directly references a web element defined within a PAGE_NAME
properties file. It is the identifier or key associated with a specific web element's locator.
Relationship with PAGE_NAME
Each
ELEMENT_NAME
is defined within aPAGE_NAME
property file.The
PAGE_NAME
property file acts as a repository for allELEMENT_NAME
entries and their corresponding locators.ELEMENT_NAME
allows the automation script to abstract the direct locator details and refer to elements in a readable and maintainable way.
Example Usage
Given a SwagLabs.properties
file with the following content:
# SwagLabs.properties
pageTitle = CSS -> .login_logo
userName = CSS -> #user-name
password = CSS -> #password
loginButton = CSS -> .btn_action
errorMessage = CSS -> .error-message-container.error
An automation script would use ELEMENT_NAME
as follows:
# Example automation script snippet
PAGE_NAME, WAIT_TYPE, SCROLL_TYPE, ELEMENT_NAME, ACTIONS, SEND_KEYS, VALIDATION, VALIDATION_TYPE
SwagLabs, VISIBILITY, NONE, userName, SEND_KEYS, testuser, NONE, NONE
SwagLabs, VISIBILITY, NONE, password, SEND_KEYS, testpassword, NONE, NONE
In this snippet:
userName
andpassword
areELEMENT_NAME
entries.The automation framework searches for these within the
SwagLabs.properties
file to find the corresponding locators.
Advantages of Using ELEMENT_NAME
Maintainability: Changes to element locators need only be updated in the property files, not in every individual test script.
Readability: Scripts are more readable and understandable when using meaningful
ELEMENT_NAME
entries.Scalability: New elements can be added to the property files without altering the test scripts.
Last updated
Was this helpful?