Demonstration of:
- Playwright browser automation testing
- Python programming language
- Chromium open source web browser
Install Python from https://www.python.org/
Run this to confirm your version:
python --versionOutput should be at least:
Python 3.13.3
Install Playwright and whichever browsers you want:
pip install playwright
playwright install chromium
playwright install firefox
playwright install webkitOptional for type checking:
pip install mypyRun:
pip install --upgrade pip
pip install --upgrade playwright
pip install --upgrade mypyRun:
src/demo.pyIf you prefer, you can run with python explicitly:
python src/demo.pyIf you prefer, you can run with type checking:
mypy src/demo.pyThe script will do three things:
-
Launch your local Chrome web browser to view the free open source testing examples web page https://testingexamples.github.io.
-
Interact with the web page in various ways, such as finding elements, clicking on elements, filling in form inputs, etc.
-
Print some typical HTML tag output that demonstrates the program is running successfully.
Async Alternative: a commented demo_async() function showing how to use the async API if needed.
Python Type Hints:
- Full type annotations for better IDE support
- Compatible with type checkers like mypy
- Optional but recommended for larger projects
Error Handling:
- Use
tracebackmodule for detailed error reporting - Use
sys.stderrfor error output - Use
sys.exit(1)for proper exit codes
- Package: playwright-examples-using-python
- Version: 1.4.0
- Created: 2019-11-02T00:00:00Z
- Updated: 2025-04-24T13:58:02Z
- License: GPL-2.0-or-greater or for custom license contact us
- Contact: Joel Parker Henderson joel.henderson@wales.nhs.uk