Skip to main content

LLM-powered web automation library with autonomous agents

Project description

webtask

PyPI version Tests License: MIT Documentation

Easy-to-use LLM-powered browser automation — from autonomous tasks to element-level control.

Why webtask?

  • High-level tasks: Describe what you want done — the agent figures out the steps
  • Low-level control: Select any element with natural language — no CSS/XPath selectors needed

Demo

await agent.do("add 3 Flat-Head Wood Screws to the cart")

Demo

View full example

Installation

pip install pywebtask
playwright install chromium

Quick Start

from webtask import Webtask
from webtask.integrations.llm import Gemini

wt = Webtask()
agent = await wt.create_agent(
    llm=Gemini(model="gemini-2.5-flash"),
    wait_after_action=1.0,
)

await agent.goto("https://practicesoftwaretesting.com")
await agent.wait(3)

# select: pick elements with natural language
search = await agent.select("the search input")
await search.fill("pliers")

# do: simple or complex tasks — agent figures out the steps
await agent.do("click search and add the first product to cart")

# extract: get structured data from the page
price = await agent.extract("the cart total price")

# verify: check conditions
assert await agent.verify("cart has 1 item")

Features

Four core operations

await agent.do("click search and add first product to cart")  # Autonomous tasks
element = await agent.select("the search input")              # Element selection
data = await agent.extract("the cart total", MySchema)        # Data extraction
assert await agent.verify("cart has 1 item")                  # Verification

Stateful agents — Agent remembers context across tasks

await agent.do("Add pliers to cart")
await agent.do("Add a hammer too")  # Remembers previous action
agent.clear_history()               # Reset when needed

Two modes — DOM-based or pixel-based interaction

agent = await wt.create_agent(llm=llm, mode="dom")     # Element IDs (default)
agent = await wt.create_agent(llm=llm, mode="pixel")   # Screen coordinates

Browser integration — Works with new or existing browsers

agent = await wt.create_agent(llm=llm)                                  # New browser
agent = await wt.create_agent_with_browser(llm=llm, browser=browser)    # Existing browser
agent = wt.create_agent_with_context(llm=llm, context=context)          # Existing context
agent = wt.create_agent_with_page(llm=llm, page=page)                   # Existing page

Error handling — Handle task failures gracefully

try:
    await agent.do("Add item to cart")
except TaskAbortedError as e:
    print(f"Task failed: {e}")

Supported LLMs

from webtask.integrations.llm import Gemini, GeminiComputerUse, Bedrock

Gemini(model="gemini-2.5-flash")                                # 2.5 Flash
GeminiComputerUse(model="gemini-2.5-computer-use-preview")      # Visual mode
Bedrock(model="anthropic.claude-sonnet-4-20250514-v1:0")        # Claude 4 Sonnet (WIP)

You can also use your own LLM by implementing the LLM interface. See the custom LLM guide.

Links

License

MIT

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

pywebtask-0.25.1.tar.gz (66.3 kB view details)

Uploaded Source

Built Distribution

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

pywebtask-0.25.1-py3-none-any.whl (97.6 kB view details)

Uploaded Python 3

File details

Details for the file pywebtask-0.25.1.tar.gz.

File metadata

  • Download URL: pywebtask-0.25.1.tar.gz
  • Upload date:
  • Size: 66.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pywebtask-0.25.1.tar.gz
Algorithm Hash digest
SHA256 b68d2e8ba3f89c1d639344ed679df4568d9bc503ff3d8e0b93ef1c839ed1ea7b
MD5 ee51673668e719024136b456a577cdc7
BLAKE2b-256 b3c850ffd3eda51379b2063528f2a7273a1850e1b5a740bd9d2de5c8a85d2ede

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywebtask-0.25.1.tar.gz:

Publisher: publish.yml on steve-z-wang/webtask

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pywebtask-0.25.1-py3-none-any.whl.

File metadata

  • Download URL: pywebtask-0.25.1-py3-none-any.whl
  • Upload date:
  • Size: 97.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pywebtask-0.25.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c518481283515b06c7fada84e8c5c82e1a9863059e7fff79697428518a957176
MD5 f8b5727b14ede97098cd297b96d49dd1
BLAKE2b-256 613fa245962d2d7c6864d352f7d04a3ddaf0c1a6e1385b1e72df54f4e6d25d00

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywebtask-0.25.1-py3-none-any.whl:

Publisher: publish.yml on steve-z-wang/webtask

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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