Skip to main content
All CollectionsEditor
Finding a specific page element (Locators)
Finding a specific page element (Locators)

Locators are used to find a specific element on a web page. One element can have several locators.

Written by Igor Ivanovski
Updated over a week ago

What are locators and how are they used?

DOM locators are used to finding a specific element on a web page.

Steps and checks use locators to find the correct element to interact with. Usetrace uses multiple locators. An element is found when at least one of its locators matches the current web page.

Editor retrieves element attributes like name, id, name, XPath, relative XPath, and also CSS when steps and checks are created.

These attributes can then be used for the step or check to find the element one after another until the element is found.

Editing locators

In Editor, click the locator tab on the desired step to change the locator attributes for a step or a check. Note that the locators are checked in the order they appear.

The supported locators are:

  • id - the HTML element’s id

  • name - the HTML element’s name

  • XPath - an absolute or relative path to the element

  • CSS - a CSS selector locating the element

  • link text - in the case of links (anchor tags), the unique text identifying the link

  • text equals - the HTML element’s text

  • text contains - the HTML element’s text contains

The locator is used only in case it uniquely identifies the element. If you define a loose locator, for example, a CSS selector “button”, Usetrace will probably find multiple HTML elements matching the locator. In that case, Usetrace will not interact with the site. To resolve this, define a more strict locator using some unique attribute, e.g. a CSS class.

Did this answer your question?