Minimal Python client for Talk2Dom API (natural-language DOM locator).
Project description
Talk2Dom Python SDK
Minimal client SDK to call the Talk2Dom API.
Install
pip install talk2dom
# optional
pip install "talk2dom[selenium]"
# or
pip install "talk2dom[playwright]"
## Quiack Start
from talk2dom import Talk2DomClient
client = Talk2DomClient(
api_key="YOUR_API_KEY",
project_id="YOUR_PROJECT_ID",
)
# sync example
res = client.locate("click the primary login button", html="<html>...</html>", url="https://example.com")
# async exmaple
res = client.alocate("click the primary login button", html="<html>...</html>", url="https://example.com")
Environment variables
- T2D_API_KEY
- T2D_PROJECT_ID
- T2D_ENDPOINT (optional; defaults to https://api.talk2dom.itbanque.com)
Selenium ActionChains
from selenium import webdriver
import time
from talk2dom.selenium import ActionChains
driver = webdriver.Chrome()
driver.get("https://python.org")
actions = ActionChains(driver)
actions\
.go("Type 'pycon' in the search box")\
.go("Click the 'go' button")
time.sleep(2)
Playwright PageNavigator
from playwright.sync_api import sync_playwright
from talk2dom.playwright import PageNavigator
def main():
with sync_playwright() as p:
# Launch Chromium browser
browser = p.chromium.launch(headless=False)
page = browser.new_page()
navigator = PageNavigator(page)
# Navigate to python.org
page.goto("https://www.python.org")
navigator.go("Type 'pycon' in the search box")
navigator.go("Click the 'go' button")
# Wait for results to load
page.wait_for_timeout(3000)
# Close the browser
browser.close()
if __name__ == "__main__":
main()
Project details
Release history Release notifications | RSS feed
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.3.1.tar.gz
(15.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
talk2dom-0.3.1-py3-none-any.whl
(15.8 kB
view details)
File details
Details for the file talk2dom-0.3.1.tar.gz.
File metadata
- Download URL: talk2dom-0.3.1.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
723b2ab8e721ab9711c8bc0e609bff78f13fbc83ebd8a885d5653bb28b7ffe7d
|
|
| MD5 |
032801fbe2382c8e6e3e8e3415b3ae94
|
|
| BLAKE2b-256 |
57895cfa82b3b5866acc815353fff18d21147d0df08976ee5a06ea9122c64e35
|
File details
Details for the file talk2dom-0.3.1-py3-none-any.whl.
File metadata
- Download URL: talk2dom-0.3.1-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e3cccbcd1ecd5e70c0be09862bb82ce8c6a5e4a6e8922ecd0bfd8768856429c
|
|
| MD5 |
d68285fd18efc462c5a389f238a075cc
|
|
| BLAKE2b-256 |
ce58990e4a5b01ccd56a9b81b144acbf200c1de2fb34234d1a03426a2bef979b
|