Comment on page
Automated UI tests (either web or mobile), are mostly focused on performing certain actions on page's or screen's elements. One of the key challenges in writing UI tests is correctly identifying elements on the screen. Accurate element identification is very important to have stable automation tests.
If the elements are incorrectly identified, the test will misbehave and perform actions on wrong elements or just fail, not able to find any. This is called test flakiness. To prevent or minimize flaky tests, you have to make sure the UI elements are uniquely identified.
Selenium and Oxygen use
locatorsto identify UI elements. Most of Oxygen commands in
mobmodules require a locator to perform various actions on the element (such as find an element, assert element's value, etc.). Oxygen provides a wide variety of locator types (strategies) which help to identify elements by different attributes and hierarchical position.
Oxygen allows you to either generate locators automatically or write them manually using various element inspection tools. Here is what you can do:
- Use Oxygen IDE Recorder - Oxygen IDE can record Chrome browser based user interactions and generate all possible locators for the selected element. Oxygen IDE will also pre-select the most suitable locator for the specific object. See Web Recording Guide for more details.
Note: In order to record mobile application actions and locators, you will need to use a special version of Appium Desktop that supports generating Oxygen code. See Mobile Recording Guide for more details.
Oxygen provides different locator types to help to identify UI elements of web and mobile applications. To indicate which locator type to use, the
locatorparameter shall start with type
prefix. Below are various locator types and prefixes for web and mobile applications.
Here are some usage examples:
web.click('id=submit') // ID
web.type('name=firstNameInput', 'first name') // Name
web.click('https://link.com') // Link
web.click('div > button.login') // CSS Selector
web.select('//select[@id="selectGender"]', 'label=female') // XPath