Skip to main content

Minimal Python client for Talk2Dom API (natural-language DOM locator).

Project description

Talk2Dom Python SDK

PyPI PyPI Downloads Stars License CI

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

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


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.2.9.tar.gz (15.8 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.2.9-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for talk2dom-0.2.9.tar.gz
Algorithm Hash digest
SHA256 d92907932da1c3f13c162202f6ef3a3e9f05741a7e51fd2ecc2ed26dfa3cace8
MD5 4d7a3bc8a2f69462dbd78a87def895b1
BLAKE2b-256 8747266d2bd402ac4b03e9735086f6b5a12262ba9bfc667b766da6dbe7f352a9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for talk2dom-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 2da5173747ddbaf1d65edf29ba3207dd3d16238c92d28d8bfa04b38aae864ece
MD5 efdec7df2ea1b9afc9b72f3318e54444
BLAKE2b-256 d843fafcce5d0bb94b60abeee6f3c7bc9eb68dcf6c87a79682e932be2938cf6f

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