Skip to main content

A utility to help you locate UI elements using HTML and natural language.

Project description

talk2dom

talk2dom is a focused utility that solves one of the hardest problems in browser automation and UI testing:

Finding the correct UI element on a page.


🧠 Why talk2dom

In most automated testing or LLM-driven web navigation tasks, the real challenge is not how to click or type — it's how to locate the right element.

Think about it:

  • Clicking a button is easy — if you know its selector.
  • Typing into a field is trivial — if you've already located the right input.
  • But finding the correct element among hundreds of <div>, <span>, or deeply nested Shadow DOM trees? That's the hard part.

talk2dom is built to solve exactly that.


🎯 What it does

talk2dom helps you locate elements by:

  • Extracting clean HTML from Selenium WebDriver or any WebElement
  • Formatting it for LLM consumption (e.g. GPT-4, Claude, etc.)
  • Returning minimal, clear selectors (like xpath: ... or css: ...)
  • Supporting retry logic for unstable DOM conditions
  • Playing nicely with Shadow DOM traversal (you handle it your way)

🤔 Why Selenium?

While there are many modern tools for controlling browsers (like Playwright or Puppeteer), Selenium remains the most robust and cross-platform solution, especially when dealing with:

  • ✅ Safari (WebKit)
  • ✅ Firefox
  • ✅ Mobile browsers
  • ✅ Cross-browser testing grids

These tools often have limited support for anything beyond Chrome-based browsers. Selenium, by contrast, has battle-tested support across all major platforms and continues to be the industry standard in enterprise and CI/CD environments.

That’s why talk2dom is designed to integrate directly with Selenium — it works where the real-world complexity lives.


📦 Installation

pip install talk2dom

🔍 Usage Example

from talk2dom import get_html

# Get full page HTML
html = get_html(driver)

# OR get specific element HTML
html = get_html(some_element)

# Send HTML + natural language instruction to your LLM
instruction = "Click the login button"
prompt = f"User wants to: '{instruction}'\nHTML:\n{html}"

# LLM returns something like:
# css: button.login
# or
# xpath: /html/body/div[2]/form/button[1]

# You parse and use the selector

✨ Philosophy

Our goal is not to control the browser — Selenium already does that well.
Our goal is to find the right DOM element, so you can tell the browser what to do.


✅ Key Features

  • 📍 Locator-first mindset: focus on where, not how
  • 🔁 Retry wrapper for flaky pages
  • 🧠 Built for LLM-agent workflows
  • 🧩 Shadow DOM friendly (you handle traversal, we return selectors)

📄 License

Apache 2.0


💬 Questions or ideas?

We’d love to hear how you're using talk2dom in your AI agents or testing flows.
Feel free to open issues or discussions!

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

talk2dom-0.1.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

talk2dom-0.1.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file talk2dom-0.1.1.tar.gz.

File metadata

  • Download URL: talk2dom-0.1.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for talk2dom-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5833ac45c9313daaad97d08ee4014f3e6c2dfb65ab43a6da5f6e3a575f4d25e7
MD5 3c195fa58c7e7ab82282a6772a742dda
BLAKE2b-256 94e39b217ab4a2fd4f80b3e8bbafc580bb9d556d482bb983a0fe06b5725211ad

See more details on using hashes here.

File details

Details for the file talk2dom-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: talk2dom-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for talk2dom-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 596c87eff782934e8244072f151a12f479b652d970fce8db0ceaac5d24d24a7a
MD5 73b5f587fd1e3bf63528bd63f677926b
BLAKE2b-256 2fd34ef4c71b46cb695272889b3045811db8d3834bd4fb8276f109a9a3368536

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