Skip to main content

Selenium wrapper to find XPath from natural language using LLMs

Project description

Selenia

Selenium wrapper to find XPath from natural language using LLMs


🚀 Overview

Selenia lets you locate web elements using natural language queries, powered by LLMs (Large Language Models). It integrates with Selenium and supports local LLMs via Ollama.

✨ Features

  • 🔍 Find elements by describing them in plain English
  • 🤖 Pluggable LLM model clients (Ollama, OpenAI, etc.)
  • 🧪 Easy integration with Selenium WebDriver
  • 🧩 Extensible for custom model backends

📦 Installation

pip install selenia

Or from source:

pip install .

🛠️ Usage Example

from selenium import webdriver
from selenia import Selenia, OllamaServerClient, OllamaClient

#for either remote or local ollama server
driver = webdriver.Chrome()
model_client = OllamaServerClient(model_name="llama3",base_url="http://localhost:11434/api/generate")

#for local ollama 
model_client = OllamaClient(model_name="llama3")

selenia = Selenia(driver, model_client)

# Find an element by description
element = selenia.find("the search input box at the top bar")

# Find all matching elements
elements = selenia.find_all("all buttons with the text 'Submit'")

🧩 Model Clients

  • OllamaServerClient: Connects to a local Ollama server (defaults: [model_name:llama3,base_url=http://localhost:11434/api/generate])
  • OllamaClient: Uses the Ollama Python package

🧪 Running Tests

pytest tests/

📄 License

MIT


Made with ❤️ by Penielny

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

selenia-0.2.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

selenia-0.2.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file selenia-0.2.0.tar.gz.

File metadata

  • Download URL: selenia-0.2.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for selenia-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2e51c95ebe1abb92cf610adef2bcaf513fb3ad38e33d22fd86b294db74c406fc
MD5 eb03da9dd8a4fa8f731c2133cc3ce546
BLAKE2b-256 94fdbe856407002f3cd82ee9fc28e0c53aa302f8f50c2f5736626b67fc011400

See more details on using hashes here.

File details

Details for the file selenia-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: selenia-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for selenia-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f7e16ff949083f951071d9291ca2590c517c4c7a978af72d43e5e318120d5cc
MD5 7ddca198d28d209133e25c81de7dcf6b
BLAKE2b-256 3882d67d9f5f759840670a8895fb03a26439a15719c3dc30d094defd53570c7c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page