๐จโ๐ผ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_NAMEis defined within aPAGE_NAMEproperty file.The
PAGE_NAMEproperty file acts as a repository for allELEMENT_NAMEentries and their corresponding locators.ELEMENT_NAMEallows 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.errorAn 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, NONEIn this snippet:
userNameandpasswordareELEMENT_NAMEentries.The automation framework searches for these within the
SwagLabs.propertiesfile 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_NAMEentries.Scalability: New elements can be added to the property files without altering the test scripts.
Last updated
Was this helpful?