You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+90-92Lines changed: 90 additions & 92 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,86 +6,85 @@ This repository contains the automated UI test suite for the BCSS application, b
6
6
7
7
Playwright is the recommended UI testing tool for NHS England, as outlined on the [NHS England Tech Radar](https://radar.engineering.england.nhs.uk/), and has been adopted here to modernize and streamline our testing workflows.
8
8
9
-
10
-
# Origin of the Framework
9
+
## Origin of the Framework
11
10
12
11
This framework was originally based on the NHS England Playwright Python Blueprint and has since been tailored to meet the specific needs of the BCSS application. While the core utilities and conventions remain, the project has been extended with custom page object models (POMs) and new utility modules to support BCSS-specific workflows, data handling, and UI interactions.
13
12
14
13
Note: This project is actively maintained and evolving.
15
14
16
-
# Table of Contents
15
+
##Table of Contents
17
16
18
17
-[BCSS Playwright Test Suite](#bcss-playwright-test-suite)
19
-
-[Origin of the Framework](#origin-of-the-framework)
20
-
-[Table of Contents](#table-of-contents)
21
-
-[Getting Started](#getting-started)
22
-
-[Prerequisites](#prerequisites)
23
-
-[1. Install Python 3.11 or higher](#1-install-python-311-or-higher)
24
-
-[2. Set up a virtual environment (recommended)](#2-set-up-a-virtual-environment-recommended)
25
-
-[First Create the virtual environment](#first-create-the-virtual-environment)
26
-
-[Next Activate the virtual environment](#next-activate-the-virtual-environment)
Follow these steps to make sure your system is ready to run the BCSS test framework.
60
+
61
+
####1. Install Python 3.11 or higher
63
62
64
63
This framework is built using Python, so you'll need to install it first. You can download the latest version from the official [Python](https://www.python.org/downloads/) website.
65
64
66
65
To check if Python is already installed, open a terminal or command prompt and run:
67
66
68
67
`python --version`
69
68
70
-
### 2. Set up a virtual environment (recommended)
69
+
####2. Set up a virtual environment (recommended)
71
70
72
71
A virtual environment is like a sandbox—it keeps your project’s Python packages separate from everything else on your computer. This prevents version conflicts and makes your setup easier to manage.
73
72
74
73
Note: If you are using an IDE such as Visual Studio Code or PyCharm, you will normally be prompted to do this automatically.
75
74
76
-
#### First Create the virtual environment
75
+
#####First Create the virtual environment
77
76
78
77
To create and activate a virtual environment, open your terminal or command prompt in the root folder of the project (where requirements.txt lives), then run:
79
78
80
79
`python -m venv .venv`
81
80
82
81
This creates a folder called .venv that contains a clean Python environment just for this project.
83
82
84
-
If you get an error like 'python not found', try using python3 instead:
83
+
If you get an error like 'Python not found', try using Python3 instead:
85
84
86
85
`python3 -m venv .venv`
87
86
88
-
#### Next Activate the virtual environment
87
+
#####Next Activate the virtual environment
89
88
90
89
This step tells your terminal to use the Python version and packages inside .venv.
91
90
@@ -103,17 +102,17 @@ On macOS/Linux:
103
102
104
103
Once activated, your terminal will show the virtual environment name (e.g. (.venv)), indicating you're working inside it.
105
104
106
-
### 3. Install Playwright browser binaries
105
+
####3. Install Playwright browser binaries
107
106
108
107
Playwright uses real browsers to run tests. You’ll need to install these browser binaries once by running:
109
108
110
109
`playwright install`
111
110
112
111
This downloads the necessary versions of Chromium, Firefox, and WebKit so tests can run across different browser types.
113
112
114
-
## Installation & Configuration
113
+
###Installation & Configuration
115
114
116
-
### 1. Install Dependencies
115
+
####1. Install Dependencies
117
116
118
117
Before configuring anything, make sure all required packages are installed by running:
119
118
@@ -126,21 +125,21 @@ This installs all Python dependencies listed in the `requirements.txt` file, inc
126
125
127
126
Note: If you're using a virtual environment (recommended), activate it before running the install command (see previous steps).
128
127
129
-
### 2. Environment Variables
128
+
####2. Environment Variables
130
129
131
130
Create a `.env` file in the project root to store sensitive configuration values like credentials, URLs, or feature flags. Example:
132
131
133
-
```
132
+
```Bash
134
133
BASE_URL=https://bcss.example.com
135
134
USERNAME=test_user
136
135
PASSWORD=secure_password123
137
136
```
138
137
139
-
These variables are loaded automatically by the framework using python-dotenv, keeping secrets out of the codebase.
138
+
These variables are loaded automatically by the framework using `python-dotenv`, keeping secrets out of the codebase.
140
139
The actual values required for the `.env` file can be obtained from one of the testers already using this framework.
141
-
Important Note: Ensure that `.env` is added to your `.gitignore` to avoid accidentally committing secrets.
140
+
Important Note: Ensure that `.env` is added to your `.gitignore` to avoid accidentally committing secrets.
142
141
143
-
### 3. Test Configuration
142
+
####3. Test Configuration
144
143
145
144
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):
146
145
@@ -149,9 +148,9 @@ You can test the configuration has worked by running our example tests, which ca
149
148
Alternatively if you are using Visual Studio Code as your IDE, we have pre-configured this project to work with the
150
149
[Testing functionality](https://code.visualstudio.com/docs/editor/testing) so the example tests should be discovered automatically.
151
150
152
-
## Running Tests
151
+
###Running Tests
153
152
154
-
### 1. Basic Test Execution
153
+
####1. Basic Test Execution
155
154
156
155
To run all tests with tracing enabled:
157
156
@@ -163,7 +162,7 @@ To run a specific test file:
163
162
164
163
Tracing captures detailed information about each test run, including browser actions, network requests, and DOM snapshots.
165
164
166
-
### 2. Test Filtering
165
+
####2. Test Filtering
167
166
168
167
Use markers or keywords to run subsets of tests:
169
168
@@ -174,7 +173,7 @@ You can combine flags like `-v (verbose)` and `--maxfail=1` to control output an
174
173
175
174
`pytest -v --maxfail=1 --tracing on`
176
175
177
-
### 3. Viewing Trace Files
176
+
####3. Viewing Trace Files
178
177
179
178
After running tests with tracing enabled, trace files are saved in the test-results folder.
180
179
@@ -188,9 +187,9 @@ Use the interactive viewer to explore browser actions, network activity, and DOM
188
187
189
188
This is especially useful for debugging failed tests or understanding complex UI flows.
190
189
191
-
## Test Structure and Conventions
190
+
###Test Structure and Conventions
192
191
193
-
### 1. File Organization
192
+
####1. File Organization
194
193
195
194
All tests are located in the tests/ directory.
196
195
@@ -200,7 +199,7 @@ Each feature or module has its own test file, e.g.:
A Page Object Model is a design pattern that encapsulates UI interactions for a specific page or component into a dedicated class. This keeps test code clean, readable, and reusable.
265
263
266
264
Instead of writing raw selectors and actions in your test, you use methods from a page class:
Utility modules help you abstract common functionality that doesn’t belong in a specific page class. This keeps your POMs lean and your tests DRY (Don’t Repeat Yourself).
316
314
317
-
### 1. Purpose of Utility Modules
315
+
####1. Purpose of Utility Modules
318
316
319
317
- Handle reusable actions (e.g. login, file uploads, date pickers)
320
318
- Provide custom assertions or wait conditions
321
319
- Manage test data generation or environment setup
- Avoid hardcoding values—use config files or environment variables.
335
+
- Avoid hard coding values - use configuration files or environment variables.
338
336
- Document each function with a short docstring.
339
337
- Use type hints for clarity and IDE support.
340
338
341
-
### 4. Blueprint Utilities
339
+
####4. Blueprint Utilities
342
340
343
341
This blueprint provides the following utility classes, that can be used to aid in testing:
344
342
@@ -349,17 +347,17 @@ This blueprint provides the following utility classes, that can be used to aid i
349
347
|[NHSNumberTools](./docs/utility-guides/NHSNumberTools.md)| Basic tools for working with NHS numbers. |
350
348
|[User Tools](./docs/utility-guides/UserTools.md)| Basic user management tool. |
351
349
352
-
## Contributing
350
+
###Contributing
353
351
354
352
Further guidance on contributing to this project can be found in our [contribution](./CONTRIBUTING.md) page.
355
353
356
-
## Contacts
354
+
###Contacts
357
355
358
356
If you have any ideas or require support for this project, please [raise an issue via this repository](https://github.com/nhs-england-tools/playwright-python-blueprint/issues/new/choose) using the appropriate template.
Unless stated otherwise, the codebase is released under the [MIT License](LICENCE.md). This covers both the codebase and any sample code in the documentation.
0 commit comments