Find Selenium elements easily using natural language descriptions.
Project details
Selenia enables the effortless identification of Selenium elements using plain English descriptions. By harnessing a local 24 MB model, it achieves fast lookups without relying on LLMs or API keys, ensuring complete privacy and offline functionality. Say goodbye to fragile selectors that break with minor UI changes.
Selenia: A Robust Solution for Finding Selenium Elements in Plain English
Stop maintaining fragile XPath selectors and streamline your Selenium testing with Selenia. This innovative tool allows users to locate web elements using simple, natural language descriptions through a compact 24 MB local model.
find operation on a laptop CPU, such as the Apple M1, after an initial model load of just 0.4 seconds.Locators can become outdated quickly with front-end changes, leading to broken tests. While LLM-based browser agents offer flexibility, they require API keys and can incur costs with each request, often taking seconds to complete actions. Selenia is designed to be a reliable alternative that produces stable and accurate locators:
| Feature | Selenia | LLM Agents | Manual XPath/CSS |
|---|---|---|---|
| Survives UI Refactors | ✅ | ✅ | ❌ |
| Offline Capability | ✅ | ❌ | ✅ |
| Cost per Lookup | $0 | Variable | $0 |
| Latency | ms | seconds | ms |
| Consistency | ✅ | ❌ | ✅ |
| Handles Ambiguity | ✅ | ❌ | n/a |
| Multi-step Task Planning | ❌ | ✅ | ❌ |
If the goal is to enhance Selenium tests with adaptable and error-resilient locators, Selenia is a practical choice.
Integrating Selenia within existing Selenium tests is straightforward. Here’s a basic example of how to use it:
from selenium import webdriver
from selenia import Selenia
driver = webdriver.Chrome()
selenia = Selenia(driver) # Model downloads on first use
driver.get("https://www.saucedemo.com/")
selenia.find("username field").send_keys("standard_user")
selenia.find("password field").send_keys("secret_sauce")
selenia.find("the login button").click()
# Retrieve all matching elements, ranked by relevance
buttons = selenia.find_all("add to cart button")
Selenia employs a sophisticated cross-encoder model fine-tuned on 28,800 real-world description-element pairs, running efficiently on onnxruntime without requiring additional dependencies like PyTorch. The model’s performance metrics are impressive:
| Evaluation Metric | Top-1 | Top-3 | Mean Reciprocal Rank (MRR) |
|---|---|---|---|
| Selenia Model Performance | 89.4% | 96.3% | 0.933 |
For those looking to adapt Selenia to specific applications, the repository includes comprehensive instructions for training the model on custom datasets. The full training pipeline is available in training/.
Contributions are encouraged, especially in the form of reporting issues or making pull requests to improve Selenia’s performance and accuracy. Feedback, particularly concerning cases where the model struggles to identify elements correctly, is invaluable for continuous refinement.
For more information and examples, visit the repository.
Comments
0Start the conversation
Share the first comment.