Web or Mobile applications depends mostly on HTML or XML documents for defining UI structure. Document Object Model(DOM) in Browsers provides a bunch of location mechanism to search and locate Element on the page for interacting with it. The most prominent ones are XPath and CSS Selectors.
- XPath - XPath is a query language used to navigate through elements and attributes in an XML document.
- CSS Selectors - CSS selectors such as type, class, id, name e.t.c also allows us to select particular elements in the XML document.
In Testsigma Terminology, UI Identifiers are locator phrases that use any of the methods to locate or select the page elements and use it to select and perform actions on Web page Elements during tests using Testsigma.
We can navigate to the UI Identifiers page by going through:
Test Development > UI Identifiers
Locators supported by TestsigmaThe following is a complete list of Element identifiers or locators supported by Testsigma:
- CSS Selector
- Link Text and Partial Link Text
- Class Name
- Tag Name
XPath is a query language used to navigate through elements and attributes in an XML document. XPath locators are very powerful and flexible.
Any element on the page can be located using multiple XPath definitions and most other locators can be expressed as an XPath.
XPath can find an element by ID like this:
UI Identifier= //*[@id="email"]
2. CSS Selector:
CSS Selector is a string pattern used to identify an element based on a combination of HTML tag, id, class, and/or attributes.
1. css Selector can find an element by Id like this:
2. css Selector can find an element by class like this:
ID is the most common way of locating elements since IDs are supposed to be unique for each element as per the W3C standard. If ID tags are available for an Element and they are unique, it is the most preferred option.
ID of the element
Locating elements by Name is very similar to locating by ID, except that we use the "name="attribute instead. And moreover, name attributes are not strictly unique.
Name of the element
5. Link Text & Partial Link Text:
Finding an element with Link Text/Partial Link Text is very simple. But make sure that the link text is unique on the
web page. If there are multiple links with the same link text (such as repeated header and footer menu links), in such
cases action will be performed on the first matching element with link.
link text of the element
6. Class name:
Class name locator selects the element which matches the values specified in the attribute name “class”.
class name of the element
7. Tag name:
Tag Name locator is used to find the elements matching the specified Tag/Type Name. It is very helpful when we want to extract the content within a Tag.
tag name of the element