Skip to main content

Plain English web test automation using Selenium and Playwright. No code. No maintenance.

Project description

snakeoil-web

PyPI version Python 3.8+ License: MIT

Selector-free, self-healing web test automation.

No XPaths. No CSS selectors. No waiting. Tests that describe what users see, not how developers built it.


Install

pip install snakeoil-web

Your first test

from snakeoil_web import WebAgent

agent = WebAgent()
agent.click("Sign in")
agent.type("harish@example.com", into="Email")
agent.type("password123", into="Password")
agent.click("Sign in")
agent.verify_text("Dashboard")

That's it. No selectors. No waits. No maintenance.


Why snake-oil?

Most test automation breaks when a developer renames a CSS class or moves an element. snakeoil-web finds elements by what users actually see — visible text, labels, and position on screen — not by how the DOM is built.

# Selenium — breaks when developer renames the class
driver.find_element(By.XPATH, '//button[@data-testid="login-btn"]').click()

# snakeoil-web — works regardless of how the DOM changes
agent.click("Sign in")

When the DOM changes, your tests don't.


Two ways to write tests

Pythonic — IDE guided, autocomplete friendly:

agent = WebAgent()
agent.click("Sign in")
agent.type("harish@example.com", into="Email")
agent.verify_text("Dashboard")

English — human readable, shareable with non-developers:

agent = WebAgent()
agent.run([
    'click "Sign in"',
    'type "harish@example.com" into "Email"',
    'verify text "Dashboard" is present',
])

Using variables

Pythonic — pass variables directly:

email    = "harish@example.com"
password = "secret123"

agent.type(email, into="Email")
agent.type(password, into="Password")
agent.click("Sign in")

English — embed variables with f-strings:

email    = "harish@example.com"
password = "secret123"

agent.run([
    f'type "{email}" into "Email"',
    f'type "{password}" into "Password"',
    'click "Sign in"',
])

Mix Pythonic and English freely

Use whichever style fits each step — they work together in the same test:

from snakeoil_web import WebAgent

# Get test data from your API
user = api.create_test_user()

agent = WebAgent()

# English for readable setup steps
agent.run([
    'click "Sign in"',
    f'type "{user.email}" into "Email"',
    f'type "{user.password}" into "Password"',
    'click "Sign in"',
])

# Pythonic for assertions — IDE helps you get it right
agent.verify_text("Dashboard")
balance = agent.extract_text(next_to="Balance")

# Back to Python for logic
assert balance == user.expected_balance

# English for teardown
agent.run([
    'click "Settings"',
    'click "Sign out"',
])

Spatial targeting

No visible text on that icon button? Use its position instead.

agent.click("button", below="Total Price")
agent.click("icon", next_to="Search")
agent.click("button", index=2)
agent.extract_text(next_to="Balance")
agent.verify_text("$0.00", next_to="Balance")

Mix with Python

Use Python for data setup, snakeoil for the UI steps.

from snakeoil_web import WebAgent

user = api.create_test_user()

agent = WebAgent()
agent.type(user.email, into="Email")
agent.type(user.password, into="Password")
agent.click("Sign in")
agent.verify_text("Dashboard")

balance = agent.extract_text(next_to="Balance")
assert balance == user.expected_balance

Configuration

Create a snakeoil.web.config.py in your project root:

URL      = "https://yourapp.com"
BROWSER  = "chromium"   # chromium | firefox | webkit | msedge
HEADLESS = False
TIMEOUT  = 30_000       # milliseconds
MAXIMIZED = True

Supported browsers

Browser Support
Chrome / Chromium
Firefox
Safari / WebKit
Edge

Related packages


Status

Early development. Feedback and contributions welcome.

GitHub · PyPI

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

snakeoil_web-0.1.4.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

snakeoil_web-0.1.4-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file snakeoil_web-0.1.4.tar.gz.

File metadata

  • Download URL: snakeoil_web-0.1.4.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for snakeoil_web-0.1.4.tar.gz
Algorithm Hash digest
SHA256 8e55fb43b604075a91d868adca356a26f6a5ea92fbf1377b4a0ee459af96daf4
MD5 14de45cb354c0b3424c38d6548103c4c
BLAKE2b-256 1c480d07a876d52afc8b863469101795574c64c9d7b2bb033ff8ad139409451d

See more details on using hashes here.

File details

Details for the file snakeoil_web-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: snakeoil_web-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for snakeoil_web-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 af870897e4ee07079b23d9b4a6a430b681ebf077207f5f077b2828605fd04771
MD5 838556806b0687bcf5db7b8ab6134b23
BLAKE2b-256 80bfe35486d149053415d5d0525d17c4766ed049c0947f3b31052d9d974dc963

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