Why AI Selectors?
Writing CSS selectors by hand is tedious and error-prone. Class names like.sc-abc123 or .v2-product-card__title--active are brittle — they change whenever a site updates its CSS-in-JS or styling framework.
The AI Selector Generator analyzes the visible page structure and intent (e.g., “the submit button”) and produces selectors based on stable signals: semantic HTML attributes, aria-label, data-testid, accessible roles, and visible text — selectors that survive minor restyling.
How It Works
- You click the AI Selector Finder icon next to a selector field.
- Figranium captures the page’s current HTML structure.
- The HTML is sent to the configured AI provider (Gemini or Claude) with a prompt describing what element you’re targeting.
- The AI returns a CSS selector.
- Figranium validates the selector against the live DOM and inserts it into your task.
Supported AI Providers
| Provider | Model | Environment Variable |
|---|---|---|
| Google Gemini | Gemini 2.0 Flash | GEMINI_API_KEY |
| Anthropic Claude | Claude (latest) | CLAUDE_API_KEY |
Setup
Option 1: Google Gemini
- Obtain a Gemini API key from Google AI Studio.
- In Figranium, go to Settings > System > AI Selector.
- Select Gemini as the provider.
- Enter your API key and save.
GEMINI_API_KEY in your environment before starting the server.
Option 2: Anthropic Claude
- Obtain a Claude API key from Anthropic Console.
- In Figranium, go to Settings > System > AI Selector.
- Select Claude as the provider.
- Enter your API key and save.
CLAUDE_API_KEY in your environment.
Using the AI Selector Finder
- Open a task in the Task Editor.
- Add or select an action block (Click, Type, Wait for Selector, etc.).
- Click the magic wand / AI icon in the selector field.
- A panel opens showing the current page preview.
- Click the element you want to target, or describe it in text (e.g., “the blue submit button”).
- The AI generates a selector. You can accept it, regenerate, or edit it manually.
Setting the Default Selector Tool
Choose between the standard Highlight Tool (point-and-click visual picker) and the AI Selector Finder as your default:- Go to Settings > System.
- Under Selector Finder, choose your preferred default.
Tips for Best Results
- Describe intent clearly: Instead of clicking randomly, use the text description field: “the ‘Add to Cart’ button inside the product detail panel”.
- Use AI for complex pages: React/Vue SPAs with auto-generated class names benefit most from AI selectors.
- Always verify: The AI may occasionally suggest a selector that matches multiple elements. Test it using the browser console.
- Combine approaches: Use AI to generate a starting selector, then manually refine it to add
:nth-child,:visible, or other constraints.