Skip to content
You're viewing the v2 docs. Looking for v1?Go to v1 docs
Docs
Testsigma
Popular questions
↑↓ to navigate↵ to selectesc to close
Book a demo

Elements

An element is a UI component a test step acts on, such as a field, a button, or a link. Testsigma stores elements in a repository, so a step refers to an element by name and every step using it picks up a change at once.

Create elements by recording them from the running application, or by entering the locator yourself.

A locator tells Testsigma how to find the element on screen. Web applications support 7 types.

LocatorWhat it matchesExample
XPathA path through the page’s structure, using elements and attributes. Any element can be written several ways, and most other locators can be expressed as an XPath//input[@id="email"]
CSS SelectorA pattern combining tag, id, class, and attributes. The only locator that reaches inside a Shadow DOMinput#email or input.inputtext
Link Text and Partial Link TextThe visible text of a link, in full or in partForgot password?, or Forgot for partial
IDThe id attribute, which the W3C standard expects to be uniqueemail
NameThe name attribute, which is not strictly uniqueuserName
Class NameThe class attributeinputtext
Tag NameThe tag itself, useful for pulling the content inside itinput

ID is the first choice when an element has a unique one. Link text has to be unique on the page: when several links share it, such as repeated header and footer menus, the step acts on the first match.

Android and iOS applications support 5 types, in this order of preference:

  • Accessibility ID: the first choice. The same value carries across Android and iOS, which makes a test easier to port, and it is the least likely to change when the source is restructured
  • ID: the second choice. Every element is supposed to have a unique one
  • XPATH: parses the source to reach the referred element
  • Class Name: the value of the element’s Class Name attribute
  • Name: the value of the element’s Name attribute

If you cannot find IDs for your elements, ask your developer to add them.

A unified mobile element stores an Android locator and an iOS locator under one name, and the types can differ per platform: XPath on Android with Accessibility ID on iOS works, as long as each value uniquely identifies the element on its platform.

Manual creation suits dynamic applications, where an element’s attributes change between sessions and a recorded locator stops matching.

Go to Create Tests > Elements, click Create Element, fill in the fields, and click Create element. The element is saved to the elements list.

  • Name: what you call the element in test steps
  • Screen Name: the screen or page the element sits on, used to group elements
  • Element Type: XPATH, ID, Name, Class Name, or Accessibility ID. These are the 5 types the dropdown offers
  • Enter Value: the locator value for the type you selected

The Create Element panel, with the name, screen name, element type, and value fields

You can also create an element while writing a step. Open a test case, add a step that takes an element, hover over the element placeholder, and select Create Element from the dropdown.

Writing a locator by hand needs a working knowledge of XPath and CSS selectors.

For a Unified Mobile application, the Create Element overlay carries an Android tab and an iOS tab. Select the Element Type and enter the value on each tab, for one platform or both: an element with a locator for only one platform is usable when a test case runs on that platform.

Leave Auto heal element during execution checked to let Testsigma recover this element’s locator if it changes, or clear it to opt out.

Each platform’s locator updates independently in the Update Element overlay: changing one never touches the other.

Right-click the element in Chrome and select Inspect. The Elements panel opens with your element highlighted in blue, showing its HTML.

HTML elements follow this shape, where the tag name, the attribute names, and the values in quotes are all candidates for a locator:

<input type="submit" name="Submit" class="button" id="btnLogin" value="LOGIN">

Here the tag name is input, and the attributes are type, name, class, id, and value. Build the element from a single attribute whose value is unique, from a link’s visible text, or from an XPath or CSS selector you write against that HTML. ID is the preferred single attribute.

The recorder flow depends on the application type.

Recording needs the Testsigma Chrome extension and an application you can reach.

  1. Go to Create Tests > Elements and click Record.

  2. Enter the URL to capture from in the new tab. The recorder opens and waits.

  3. Hover over an element until it highlights in green.

  4. Click it and wait for it to appear in the recorder.

  5. Repeat for every element you want.

  6. Click Stop.

The Record Elements panel over the application, listing a captured element and its screen name

The recorder returns you to the Elements page with everything you captured.

Locator precedence tells the recorder which locator type to reach for first, across Link Text, Name, ID, CSS Selector, and XPath. The recorder works down your order and takes the first locator that is static and unique.

  1. Go to Create Tests > Elements and click Record.

  2. Click Locator precedence in the recorder.

  3. Drag the handles into the order you want.

  4. Click Save.

The Locator precedence panel in the recorder, with the locator types in draggable order

Verify an element during recording rather than waiting for a run to fail on it.

  1. Open a test case and click Record.

  2. Hover over the element in a step, click it, and select Edit Element.

  3. Click Verify in the Update Element screen. The element highlights on the page.

  4. If the element does not exist, a message says so. Correct the locator and verify again until it highlights.

The Update Element panel in the recorder, with Verify below the captured element image

Go to Create Tests > Elements, click the ellipsis icon (⋮) next to the element, and click Edit. Change the Name, Screen Name, Element Type, or Element Value in the Update Element overlay, and click Update. Clicking the element opens Element Details, where Edit opens the same overlay.

To update many elements at once, export them, change the fields you need, and import the file back. See Import and export elements.

An image element identifies a control by pixel recognition instead of the DOM, which helps when dynamic behavior keeps breaking an XPath.

  1. Go to Create Tests > Elements and click Create Element.

  2. Click Record Element to open the recorder.

  3. Enter the Name and Screen Name, and select Image as the Element Type.

  4. Click Capture to take the element from the screen, or Upload to supply a screenshot.

  5. Select the part of the screen that holds the element, and click Capture.

Capture Element in the recorder, with Image as the element type and Capture or Upload for the image

Crop the capture tight to the control, with even padding on all sides. A capture that includes surrounding background, or cuts the control off, matches less reliably.

Tight, evenly padded captures work; loose, cropped, or context-heavy ones do not

The element is saved to the elements list. You can also do this from a test case: click Record, create a step that takes an element, click the element, and select Create Element.

A Shadow DOM attaches a hidden DOM tree to an element, keeping its styles and markup separate from the main page. Those elements do not exist in the main DOM, so ordinary locators cannot reach them. Only a CSS selector can.

To check whether a page uses one, right-click the page, select Inspect, expand the <body> tag on the Elements tab, and look for #shadow-root.

TermWhat it is
Shadow hostThe HTML element the shadow DOM is attached to
Shadow treeThe hidden tree of DOM elements inside the shadow DOM
Shadow boundaryThe line separating the shadow DOM from the main DOM
Shadow rootThe root node of the hidden tree

Chrome DevTools showing a #shadow-root in the element tree, with Copy selector in the context menu

Capture one from Create Tests > Elements: click Create Element, click Record Element in the overlay, open the page in a new tab, click the element, and click Capture.

The recorder captures the iframe details with the element, so a test case works without the switch to the frame NLP.

If you do use switch to the frame, edit every iframe element in that test case and clear present inside nested content.

When part of a locator changes between runs, put the changing part in test data and reference it from the locator. Testsigma accepts parameterized XPath and CSS selectors, taking the variable from a test data profile parameter, from environment data, or from a runtime variable. This is what makes a data-driven test work against elements whose attributes shift.

Reference an environment parameter in the locator with *|parameter_name|. If the username on screen is dev-admin on Dev and qa-admin on QA, store it as an environment parameter and write the locator as //button[text()='*|username|']. Testsigma substitutes the environment’s value at runtime.

For a value that only exists mid-run, store it into a runtime variable with an NLP first, then reference that variable in the locator. Recording a dynamic element is unreliable, so create these elements manually.

For an element in a table, copy a working XPath first: right-click the element, select Inspect, then right-click the highlighted HTML and select Copy > Copy XPath. Generalize the row or column position from there.

A date widget marks today’s date with its own class, and the class differs by date library but follows a pattern. In a JQuery UI date picker, today carries ui-state-highlight, so today, tomorrow, and any later day are:

//td/a[@class='ui-state-default ui-state-highlight']
//td/a[@class='ui-state-default ui-state-highlight']/following::td[1]
//td/a[@class='ui-state-default ui-state-highlight']/following::td[7]

An overlay that closes the moment you inspect it can be frozen. Open DevTools, go to the Sources tab, bring the application to the state you need, and click Pause script execution. When clicking the page closes the overlay first, trigger the click from the console on a delay instead:

element1 = document.querySelector("#gbwa");
setTimeout(function() {
element1.click();
}, 3000);

Disabling JavaScript temporarily also works, but not reliably.

Mobile automation on Flutter reads the app’s semantics tree, not its widget tree. An element is identifiable only when its widget carries a semantic label.

Most built-in Flutter widgets set semantic properties already. Custom widgets often do not, and semantics for several widgets can be merged into one, which hides the individual elements. When an element cannot be identified, the app developer has to set the semantic label on that widget.

Search by name from the search bar on the Elements List page.

Sort by Title, Created Date, or Updated Date.

To filter, click Show Filters > Add Filter and pick from Element Value, Name, Linked to Test Case, Labels, Screen Name, Element Type, Created By, Created Date, and Updated Date, along with any custom field. Filters stack. Click Reset or All to clear them.

To keep a filter, click Save Filter > As New, name it in Config Name, and select Public to share it with everyone who can access the project. Saved filters sit under Saved Filters, split into Custom and Predefined, where you can edit or delete each one.

Click View in an element’s affected list to see the test cases, step groups, test suites, and test plans a change to it would reach.

Larger teams can turn on review management for elements, so an element is reviewed before it joins a regression suite, the same way a test case is.

Import and export move elements between application versions, in the same project or a different one. They also handle bulk edits: export the elements, change them in the file, and import the file back.

To import, go to Create Tests > Elements, click Import, click Browse File and select your file, choose Overwrite or Ignore for duplicates, then click Import.

The element Import panel, with the uploaded file and the Overwrite or Ignore choice for duplicates

To export, go to Create Tests > Elements and click Export.

Both run in the background, and Testsigma emails you when they finish.

ColumnWhat it holds
UUIDThe element’s unique identifier, present only on exported elements
Name / fieldNameThe element’s name
Screen Name / screenNameThe screen the element sits on, used for grouping
Locator Type / locatorTypeThe type of locator
Value / fieldDefintionThe locator value for that type
Created Using / createTypeHow the element was created

A development team can use the same route to hand over locators for UAT, adding custom attributes to the application to make it more testable and supplying them as a spreadsheet.

Was this page helpful?