Skip to main content

Semantic intent-based self-healing test locators for QE and test automation

Project description

PyPI version Python

CANVAS

Context-Aware Navigation and Visual Anchoring System for Selectors

An open source research prototype for semantic intent-based self-healing test locators, built for the QE and test automation community.

Why CANVAS

Existing self-healing tools use attribute-based matching — CSS selectors, XPath, element IDs, class names. These break whenever a UI undergoes structural redesign, even when the element's function is unchanged.

CANVAS takes a different approach: semantic intent anchoring. At record time it encodes what an element does — its role, accessible label, workflow position, and surrounding context — into a dense vector using a local sentence-transformers model. At runtime it embeds live DOM candidates and finds the nearest semantic match, then gates the decision:

  • Auto-heal if confidence is high enough
  • Request human confirmation if confidence is in a grey zone
  • Fail explicitly if no confident match exists

This means a "Submit Order" button that moves from a sidebar to a modal, or gets its ID changed from #btn-submit to #cta-primary, can still be found — because its intent is preserved even when its address is not.

What's inside (v0.2.0)

  • Semantic intent anchoring — encodes role, accessible label, heading context, landmark, and visible text into a dense vector
  • Shadow DOM piercingextract_from_playwright uses the Playwright ElementHandle approach, natively reaching into shadow roots
  • Visibility and disabled-state filtering — the resolver skips hidden and disabled candidates automatically
  • Bounding box capture(x, y, width, height) geometry to disambiguate duplicate-intent elements
  • Page/flow context — intents are scoped to a URL, so a checkout Submit is never confused with a login Submit
  • Healing audit log + JUnit XML export — structured healing decisions for CI dashboards
  • Multilingual model support — swap in paraphrase-multilingual-MiniLM-L12-v2 (or any sentence-transformers model)
  • Re-record CLIcanvas-heal rerecord / list / audit

Status

All phases complete. v0.2.0 published to PyPI as canvas-heal.

Roadmap

Phase Name Status
1 Semantic Element Descriptor Complete
2 Intent Embedding Complete
3 Confidence-Gated Resolver Complete
4 Adversarial Testing Complete

Structure

canvas_heal/        — core source code
  descriptor.py     — DOM element descriptor extraction (+ shadow DOM, bounding box)
  embedder.py       — sentence-transformers embedding pipeline
  resolver.py       — confidence-gated semantic resolver + SQLite intent store
  cli.py            — canvas-heal command-line interface
tests/              — unit tests and adversarial test scenarios
docs/               — technical documentation

Quick Start

pip install canvas-heal
python -m playwright install chromium
python -m pytest tests/ -v
# Re-record an intent against a live URL
canvas-heal rerecord --url https://yourapp.com/checkout --selector "#submit-btn" --name checkout_submit --db tests/intents.db

CLI reference

The canvas-heal command provides three subcommands:

  • canvas-heal rerecord — capture a fresh intent from a live page. Flags: --url <page>, --selector <css>, --name <intent-name>, --db <path>.
  • canvas-heal list — list recorded intents in a database. Flags: --db <path>.
  • canvas-heal audit — print the healing audit log. Flags: --db <path>.

Contributing

CANVAS is in early prototype stage. Community feedback, issues, and pull requests are welcome once Phase 4 (adversarial testing) is complete. Watch the repo or open a discussion if you want to get involved earlier.

License

MIT — see LICENSE

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

canvas_heal-0.3.0.tar.gz (75.2 kB view details)

Uploaded Source

Built Distribution

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

canvas_heal-0.3.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file canvas_heal-0.3.0.tar.gz.

File metadata

  • Download URL: canvas_heal-0.3.0.tar.gz
  • Upload date:
  • Size: 75.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for canvas_heal-0.3.0.tar.gz
Algorithm Hash digest
SHA256 93515da900630d359243aa48604a314d5e35e805969bc78d6c7b29f6f36c894a
MD5 91293fad296d226781317ad8cdf1644c
BLAKE2b-256 991786a1730a7628ab9d8cb50ab838e19eeaaea1ce1a70a9f1075aeae9681064

See more details on using hashes here.

File details

Details for the file canvas_heal-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: canvas_heal-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for canvas_heal-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27025261a815afcbeebb713a99e8468e8f4dac0b7aad7593f12e461ae829bb68
MD5 33b25946769eb700a0c8d5208ac78587
BLAKE2b-256 bd6c4231cf49f2ba8b4075924cc339e27c043875ab9c1f14d9c7c8d1141062a2

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