Skip to main content
Selectors are the “coordinates” Figranium uses to find and interact with elements on a webpage. Figranium relies primarily on CSS Selectors, with additional Playwright-specific extensions for text-based and visibility-based matching.

Basic Selectors

Combining Selectors

Pseudo-Classes

Prefer IDs and data-* attributes for the most stable selectors. Avoid long descendant chains that break when the DOM structure changes.

Testing Selectors

Figranium provides multiple tools for finding and verifying selectors:

Built-in Highlight Tool

Click the selector/crosshair icon in any action block’s selector field. This activates a visual picker in the headful browser that lets you hover over and click elements on the live page. When you click an element, Figranium generates up to five selector candidates ranked by stability and readability. The top candidate is automatically inserted into the selector field, and the remaining alternatives appear as clickable pill buttons below the input. Click any alternative to switch. The selector generation algorithm prioritizes selectors in this order:
  1. Name and placeholder attributes[name="email"], [placeholder="Search..."]
  2. Text content:has-text("Submit") for buttons, links, and labels
  3. Semantic attributes[aria-label="Close"], [title="Settings"], [alt="Logo"]
  4. Data attributes[data-testid="login-btn"], [data-cy="submit"]
  5. IDs#checkout-form (skips random or obfuscated IDs)
  6. Other attributes[type="submit"], [href="/account"]
  7. Classes.product-card (skips auto-generated hashes like .sc-abc123)
  8. Structural fallbacktag:nth-of-type(n) or parent path
This priority order means you get human-readable, resilient selectors by default, with structural fallbacks only when no better option exists.

AI Selector Generator

Uses AI (Gemini or Claude) to generate robust, semantically meaningful selectors. It analyzes the page structure and suggests selectors that are more resilient to minor HTML changes. Configure your AI provider keys in Settings > System > API Keys and choose the preferred model in Settings > System > AI Models. Set your preferred default selector tool in Settings > System > Selector Finder.

Browser Developer Tools

1

Inspect the element

Right-click an element > Inspect.
2

Search for matches

In the Elements panel, press Ctrl+F (or Cmd+F on Mac).
3

Type and verify

Type a CSS selector or XPath to see highlighted matches in real-time.
4

Copy the selector

Right-click the element in the Elements tree > Copy > Copy selector for an auto-generated selector.

Testing in the Browser Console

Verify a selector in DevTools console:

Best Practices

  1. Prefer IDs and data-* attributes: IDs (#submit) and test attributes ([data-testid="submit"]) are the most stable because they are explicitly set by developers and less likely to change with styling updates.
  2. Avoid long chains: body > div > div > section > ul > li > span breaks as soon as the HTML structure changes. Use a more specific class or attribute closer to the element.
  3. Use :has-text() for dynamic buttons: When a button’s text is the most stable thing about it, use button:has-text("Add to Cart") rather than a brittle class like .btn-blue-v2.
  4. Scope your selectors: Instead of .item, use .product-list .item to avoid accidentally matching elements in other parts of the page.
  5. Avoid nth-child on large lists: li:nth-child(7) breaks when items are added/removed. Use a data attribute or text match instead.
  6. Test after site updates: Websites change. Pin important selectors to stable attributes and review them periodically.
When a selector feels brittle, switch to the Highlight Tool or AI Selector Generator to find a more stable alternative before it breaks in production.