Selenia
Selenium wrapper that finds elements from natural language using a small local model
🚀 Overview
Selenia lets you locate web elements by describing them in plain English. A small fine-tuned model (about 24 MB, CPU only, no PyTorch) scores the real elements on the page against your description and returns the best one. Nothing leaves your machine, and it never invents a selector.
✨ Features
- 🔍 Find elements by describing them in plain English
- ⚡ Runs locally on CPU: no LLM, no server, no API key
- 🛑 Refuses to guess: raises when no element fits or when two fit equally well
- 🧪 Easy integration with Selenium WebDriver, including elements inside open shadow DOM
- 🧩 Retrain on your own pages with the kit in training/
📦 Installation
pip install selenia
Or from source:
pip install .
🛠️ Usage Example
from selenium import webdriver
from selenia import Selenia
driver = webdriver.Chrome()
selenia = Selenia(driver) # downloads the model 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()
# Find all matching elements, best match first
buttons = selenia.find_all("add to cart button")
🧩 The model
The first time you create a Selenia, it downloads the model (about 24 MB) into ~/.cache/selenia
and verifies its checksum. After that it runs offline.
SELENIA_CACHE_DIRchanges where the download is kept.SELENIA_MODEL_URLfetches from your own mirror instead of the GitHub release.- To use a model you trained yourself, pass
LocalRanker(model_dir="training/models/selenia-ce")or setSELENIA_MODEL_DIR. That is the folder written bytraining/train.py.
🎯 How matches are chosen
findraises Selenium'sNoSuchElementExceptionwhen the model is not confident (min_score, default 0.5) or when two elements fit equally well (min_margin, default 0.05). The message names the candidates, so you can see what to add to the description.find_allreturns every element scoring at leastmin_score, best first.- Tune both with
LocalRanker(min_score=..., min_margin=...);min_margin=0always takes the top pick. - iframes are not searched: switch into the frame first, then call
find.
See training/README.md to train or improve the model on your own pages.
🧪 Running Tests
python -m pytest tests/
The tests in tests/test_browser.py drive a headless Chrome against a local page and are skipped
when Chrome cannot start. The ones that use the real model are also skipped unless a trained model
is at training/models/selenia-ce or SELENIA_MODEL_DIR.
📄 License
MIT
Made with ❤️ by Penielny
Metadata
Release files for selenia 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| selenia-0.3.0.tar.gz | 16.4 kB | With provenance | Details for selenia-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| selenia-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for selenia-0.3.0-py3-none-any.whl |
Total release size: 27.6 kB
Release files / selenia-0.3.0.tar.gz
| Download URL | selenia-0.3.0.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a04aad8676c4deeee019904f3ac541cce5f9cbb1db87b44049d4e746868f02ec
|
|
BLAKE2b-256 checksum How to use checksums |
9d78c87c8d91a18ce940c226eb92ecfa745fde9fe739d1a70fc4b45406e0294c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logRelease files / selenia-0.3.0-py3-none-any.whl
| Download URL | selenia-0.3.0-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b7bafb2dcd0decce5ef5217fe4092900dd54242857435f99fcb2578e8d559b1
|
|
BLAKE2b-256 checksum How to use checksums |
a30f43f9cc2c63178600c3cbe71b3fd2d64f445d414b0e0a3bd712dd1302b3b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logSecurity for selenia 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for selenia-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.