This project is designed to provide a blueprint to allow for development teams to start quickly developing UI tests using Playwright Python, providing the base framework and utilities to allow for initial focus on writing tests, rather than configuration of the framework itself.
NOTE: This project is currently under initial development so isn't finalised, but should work if you want to experiment with Playwright Python.
NOTE: When considering this project, please be advised that currently Playwright is a "proposed" tool within the NHS England Tech Radar. Whilst we are taking steps to get Playwright moved to the "mainstream" section of the radar, as it has not yet been formally adopted it is possible that Playwright may not be fully endorsed by NHS England as a standard tool going forward, and using this framework for an NHS England project is currently at your own risk.
You can clone this whole repository using the code below:
git clone https://github.com/nhs-england-tools/playwright-python-blueprint.git
To utilise the blueprint code, you will need to have the following installed:
- Python 3.12 or greater
NOTE: There are currently known issues with Python 3.13 and Playwright, so if you encounter issues running this project whilst using Python 3.13 it is recommended to downgrade to Python 3.12 in the interim.
Whilst not required to get started, you may also want to configure a Python virtual environment for your project before proceeding with the configuration. If you are using an IDE such as Visual Studio Code or PyCharm, you will normally be prompted to do this automatically.
To get started using Playwright and with the examples provided, use the following commands:
pip install -r requirements.txt
playwright install --with-deps
This will install all the necessary packages for executing Playwright tests, and install Playwright ready for use by the framework. You can test the configuration has worked by running our example tests, which can be done using the following command (this will run all tests with tracing reports turned on, and in headed mode so you can see the browser execution):
pytest --tracing on --headed
NOTE: This section is currently under development and requires further work, so links to pages within this repository may not be very useful at this stage.
Once you've confirmed your installation is working, please take a look at the following guides on getting started with Playwright Python.
We've also created a Quick Reference Guide for common commands and actions you may regularly perform using this blueprint.
For additional reading and guidance on writing tests, we also recommend reviewing the Playwright Python documentation.
This blueprint also provides the following utility classes, that can be used to aid in testing:
Utility | Description |
---|---|
Axe | Accessibility scanning using axe-core. |
Date Time Utility | Basic functionality for managing date/times. |
NHSNumberTools | Basic tools for working with NHS numbers. |
Further guidance on contributing to this project can be found in our contribution page.
If you have any ideas or require support for this project, please raise an issue via this repository using the appropriate template.
If you have any general queries regarding this blueprint, please contact [email protected].
Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation.
Any HTML or Markdown documentation is © Crown Copyright and available under the terms of the Open Government Licence v3.0.