|
1 | 1 | # Playwright Python Blueprint |
2 | 2 |
|
3 | | -[](https://github.com/nhs-england-tools/repository-template/actions/workflows/cicd-1-pull-request.yaml) |
4 | | -[](https://sonarcloud.io/summary/new_code?id=repository-template) |
| 3 | +[](https://github.com/nhs-england-tools/playwright-python-blueprint/actions/workflows/cicd-1-pull-request.yaml) |
5 | 4 |
|
6 | 5 | This project is designed to provide a blueprint to allow for development teams to start quickly developing UI tests using [Playwright Python](https://playwright.dev/python/), providing the base framework and utilities to allow for initial focus on writing tests, rather than configuration of the framework itself. |
7 | 6 |
|
8 | 7 | NOTE: This project is currently under initial development. |
9 | 8 |
|
| 9 | +> **NOTE: When considering this project, please be advised that currently Playwright is a "proposed" tool within the [NHS England Tech Radar](https://radar.engineering.england.nhs.uk/). 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 at your own risk.** |
| 10 | +
|
10 | 11 | ## Table of Contents |
11 | 12 |
|
12 | 13 | - [Playwright Python Blueprint](#playwright-python-blueprint) |
13 | 14 | - [Table of Contents](#table-of-contents) |
14 | 15 | - [Setup](#setup) |
15 | 16 | - [Prerequisites](#prerequisites) |
16 | 17 | - [Configuration](#configuration) |
17 | | - - [Usage](#usage) |
18 | | - - [Testing](#testing) |
19 | | - - [Design](#design) |
20 | | - - [Diagrams](#diagrams) |
21 | | - - [Modularity](#modularity) |
22 | | - - [Contributing](#contributing) |
| 18 | + - [Getting Started](#getting-started) |
23 | 19 | - [Contacts](#contacts) |
24 | 20 | - [Licence](#licence) |
25 | 21 |
|
26 | 22 | ## Setup |
27 | 23 |
|
28 | | -By including preferably a one-liner or if necessary a set of clear CLI instructions we improve user experience. This should be a frictionless installation process that works on various operating systems (macOS, Linux, Windows WSL) and handles all the dependencies. |
29 | | - |
30 | | -Clone the repository |
| 24 | +You can clone this whole repository using the code below: |
31 | 25 |
|
32 | 26 | ```shell |
33 | | -git clone https://github.com/nhs-england-tools/repository-template.git |
34 | | -cd nhs-england-tools/repository-template |
| 27 | +git clone https://github.com/nhs-england-tools/playwright-python-blueprint.git |
35 | 28 | ``` |
36 | 29 |
|
37 | | -### Prerequisites |
38 | | - |
39 | | -The following software packages, or their equivalents, are expected to be installed and configured: |
| 30 | +The code for actually working in Playwright is contained in the blueprint directory, so it's best to do the following to move straight into that working directory: |
40 | 31 |
|
41 | | -- [Docker](https://www.docker.com/) container runtime or a compatible tool, e.g. [Podman](https://podman.io/), |
42 | | -- [asdf](https://asdf-vm.com/) version manager, |
43 | | -- [GNU make](https://www.gnu.org/software/make/) 3.82 or later, |
| 32 | +```shell |
| 33 | +cd nhs-england-tools/playwright-python-blueprint/blueprint |
| 34 | +``` |
44 | 35 |
|
45 | | -> [!NOTE]<br> |
46 | | -> The version of GNU make available by default on macOS is earlier than 3.82. You will need to upgrade it or certain `make` tasks will fail. On macOS, you will need [Homebrew](https://brew.sh/) installed, then to install `make`, like so: |
47 | | -> |
48 | | -> ```shell |
49 | | -> brew install make |
50 | | -> ``` |
51 | | -> |
52 | | -> You will then see instructions to fix your [`$PATH`](https://github.com/nhs-england-tools/dotfiles/blob/main/dot_path.tmpl) variable to make the newly installed version available. If you are using [dotfiles](https://github.com/nhs-england-tools/dotfiles), this is all done for you. |
| 36 | +### Prerequisites |
53 | 37 |
|
54 | | -- [GNU sed](https://www.gnu.org/software/sed/) and [GNU grep](https://www.gnu.org/software/grep/) are required for the scripted command-line output processing, |
55 | | -- [GNU coreutils](https://www.gnu.org/software/coreutils/) and [GNU binutils](https://www.gnu.org/software/binutils/) may be required to build dependencies like Python, which may need to be compiled during installation, |
| 38 | +To utilise the blueprint code, you will need to have the following installed: |
56 | 39 |
|
57 | | -> [!NOTE]<br> |
58 | | -> For macOS users, installation of the GNU toolchain has been scripted and automated as part of the `dotfiles` project. Please see this [script](https://github.com/nhs-england-tools/dotfiles/blob/main/assets/20-install-base-packages.macos.sh) for details. |
| 40 | +- [Python](https://www.python.org/downloads/) 3.12 or greater |
59 | 41 |
|
60 | | -- [Python](https://www.python.org/) required to run Git hooks, |
61 | | -- [`jq`](https://jqlang.github.io/jq/) a lightweight and flexible command-line JSON processor. |
| 42 | +Whilst not required to get started, you may also want to [configure a Python virtual environment for your project](https://docs.python.org/3/library/venv.html) before proceeding with |
| 43 | +the configuration. If you are using an IDE such as Visual Studio Code or PyCharm, you will normally be prompted to do this automatically. |
62 | 44 |
|
63 | 45 | ### Configuration |
64 | 46 |
|
65 | | -Installation and configuration of the toolchain dependencies |
| 47 | +To get started using Playwright and with the examples provided, use the following commands: |
66 | 48 |
|
67 | 49 | ```shell |
68 | | -make config |
| 50 | +pip install -r requirements.txt |
| 51 | +playwright install --with-deps |
69 | 52 | ``` |
70 | 53 |
|
71 | | -## Usage |
72 | | - |
73 | | -After a successful installation, provide an informative example of how this project can be used. Additional code snippets, screenshots and demos work well in this space. You may also link to the other documentation resources, e.g. the [User Guide](./docs/user-guide.md) to demonstrate more use cases and to show more features. |
| 54 | +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 |
| 55 | +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 |
| 56 | +so you can see the browser execution): |
74 | 57 |
|
75 | | -### Testing |
76 | | - |
77 | | -There are `make` tasks for you to configure to run your tests. Run `make test` to see how they work. You should be able to use the same entry points for local development as in your CI pipeline. |
78 | | - |
79 | | -## Design |
80 | | - |
81 | | -### Diagrams |
82 | | - |
83 | | -The [C4 model](https://c4model.com/) is a simple and intuitive way to create software architecture diagrams that are clear, consistent, scalable and most importantly collaborative. This should result in documenting all the system interfaces, external dependencies and integration points. |
84 | | - |
85 | | - |
86 | | - |
87 | | -The source for diagrams should be in Git for change control and review purposes. Recommendations are [draw.io](https://app.diagrams.net/) (example above in [docs](.docs/diagrams/) folder) and [Mermaids](https://github.com/mermaid-js/mermaid). Here is an example Mermaids sequence diagram: |
88 | | - |
89 | | -```mermaid |
90 | | -sequenceDiagram |
91 | | - User->>+Service: GET /users?params=... |
92 | | - Service->>Service: auth request |
93 | | - Service->>Database: get all users |
94 | | - Database-->>Service: list of users |
95 | | - Service->>Service: filter users |
96 | | - Service-->>-User: list[User] |
| 58 | +```shell |
| 59 | +pytest --tracing on --headed |
97 | 60 | ``` |
98 | 61 |
|
99 | | -### Modularity |
| 62 | +## Getting Started |
100 | 63 |
|
101 | | -Most of the projects are built with customisability and extendability in mind. At a minimum, this can be achieved by implementing service level configuration options and settings. The intention of this section is to show how this can be used. If the system processes data, you could mention here for example how the input is prepared for testing - anonymised, synthetic or live data. |
| 64 | +> 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. |
102 | 65 |
|
103 | | -## Contributing |
| 66 | +Once you've confirmed your installation is working, please take a look at the following guides on getting started with Playwright Python. |
104 | 67 |
|
105 | | -Describe or link templates on how to raise an issue, feature request or make a contribution to the codebase. Reference the other documentation files, like |
| 68 | +1. [Understanding Playwright Python](./docs/getting-started/1_Understanding_Playwright_Python.md) |
| 69 | +2. [Blueprint File Breakdown](./docs/getting-started/2_Blueprint_File_Breakdown.md) |
106 | 70 |
|
107 | | -- Environment setup for contribution, i.e. `CONTRIBUTING.md` |
108 | | -- Coding standards, branching, linting, practices for development and testing |
109 | | -- Release process, versioning, changelog |
110 | | -- Backlog, board, roadmap, ways of working |
111 | | -- High-level requirements, guiding principles, decision records, etc. |
| 71 | +For additional reading and guidance on writing tests, we also recommend reviewing the [Playwright Python documentation](https://playwright.dev/python/docs/writing-tests). |
112 | 72 |
|
113 | 73 | ## Contacts |
114 | 74 |
|
115 | | -Provide a way to contact the owners of this project. It can be a team, an individual or information on the means of getting in touch via active communication channels, e.g. opening a GitHub discussion, raising an issue, etc. |
| 75 | +If you have any queries regarding this blueprint, please contact [[email protected]](mailto:[email protected]). |
116 | 76 |
|
117 | 77 | ## Licence |
118 | 78 |
|
|
0 commit comments