Skip to main content

Selector mode

Why selectors matter​

Every element change in the Visual Editor—such as editing text, changing a style, hiding an element, moving content, or inserting HTML—is connected to the page through a CSS selector. Lyftio uses that selector to find the element again when the variation runs.

A good selector should identify the intended element reliably without depending on page details that change often.

Open selector mode​

Selector mode 1

Select an element, open the three-dot menu beside CSS selector, and choose Set selector mode.

Selector mode 2

Changes in this dialog are saved automatically in your browser. They are used the next time the editor generates a selector.

important

Changing selector mode does not rewrite selectors that have already been generated or saved. Reselect an element to generate a new selector, or use Edit in builder or Edit as text to change an existing selector.

Generation mode​

Use strict selector mode​

Strict mode creates a direct path from the selected element up to the nearest usable ID. If no usable ID is available, the path continues to the page body.

For example, a strict selector might look like:

#product-details > div.actions > button:nth-of-type(2)

Use strict mode when the page structure is predictable and you want a selector that describes the element's exact location.

When strict mode is turned off, Lyftio searches for the shortest selector that uniquely identifies the element. This can produce a selector such as #checkout-button or [data-testid="checkout-button"], which is often more resilient when surrounding containers move.

Force positional matching (nth-of-type)​

This option adds the element's position among siblings of the same tag, for example button:nth-of-type(2).

Positional matching can help when elements have changing classes or attributes. However, it can become invalid if another element is inserted, removed, or reordered before the target. Even when this option is off, the generator may use a position as a fallback when it is necessary to keep the selector unique.

Element properties​

These options control which element properties the generator may prefer when constructing a selector:

OptionHow it is used
Use element tagsIncludes HTML tag names such as button, div, or input. This is always enabled.
Use IDsUses stable IDs such as #checkout-button. IDs containing numbers are ignored because they are often generated dynamically.
Use classesUses descriptive classes such as .checkout-button. Generic, state-based, short, and number-containing classes may be ignored automatically.
Use attributesUses suitable attributes such as name, type, href, aria-label, or stable data-* attributes. Noisy, framework-generated, and purely numeric values are ignored.

The generator verifies that the resulting selector identifies only the selected element. If the preferred properties are not enough, it may combine them with ancestor elements or positional matching to produce a unique selector.

Element tree tooltip​

Enable Show tooltip in element tree to display available IDs, classes, and attributes when you hover over an item in the element tree. The tooltip shows only the property types that are enabled in selector mode.

This setting helps you inspect the page and choose another element, but it does not change selector matching by itself.

Choose settings based on how the website is built:

  • For stable, unique IDs, enable Use IDs and consider turning strict mode off to generate short selectors.
  • For stable test or data attributes, enable Use attributes and turn off unreliable classes.
  • For meaningful, consistent class names, enable Use classes.
  • For dynamic or generated classes, turn off Use classes and prefer stable IDs or attributes.
  • Use Force positional matching when the element lacks more stable identifying information.
info

More enabled properties can make a selector more specific, while fewer properties can make it more resilient to page changes. Always verify that the generated selector highlights the intended element.

note

You can edit a generated selector using the Selector Builder or Edit as text from the selector's three-dot menu.