Skip to content

Commit f9e9474

Browse files
committed
Addressed commit warnings/errors
1 parent 7f0f874 commit f9e9474

File tree

1 file changed

+90
-92
lines changed

1 file changed

+90
-92
lines changed

README.md

Lines changed: 90 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -6,86 +6,85 @@ This repository contains the automated UI test suite for the BCSS application, b
66

77
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.
88

9-
10-
# Origin of the Framework
9+
## Origin of the Framework
1110

1211
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.
1312

1413
Note: This project is actively maintained and evolving.
1514

16-
# Table of Contents
15+
## Table of Contents
1716

1817
- [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)
27-
- [3. Install Playwright browser binaries](#3-install-playwright-browser-binaries)
28-
- [Installation \& Configuration](#installation--configuration)
29-
- [1. Install Dependencies](#1-install-dependencies)
30-
- [2. Environment Variables](#2-environment-variables)
31-
- [3. Test Configuration](#3-test-configuration)
32-
- [Running Tests](#running-tests)
33-
- [1. Basic Test Execution](#1-basic-test-execution)
34-
- [2. Test Filtering](#2-test-filtering)
35-
- [3. Viewing Trace Files](#3-viewing-trace-files)
36-
- [Test Structure and Conventions](#test-structure-and-conventions)
37-
- [1. File Organization](#1-file-organization)
38-
- [2. Naming Conventions](#2-naming-conventions)
39-
- [3. Test Function Anatomy](#3-test-function-anatomy)
40-
- [4. Markers and Tags](#4-markers-and-tags)
41-
- [5. Skipping and Expected Failures](#5-skipping-and-expected-failures)
42-
- [Page Object Model (POM) Guidelines](#page-object-model-pom-guidelines)
43-
- [1. What is a POM?](#1-what-is-a-pom)
44-
- [2. Location and Structure](#2-location-and-structure)
45-
- [3. Naming Convention](#3-naming-convention)
46-
- [4. Anatomy of a Page Class](#4-anatomy-of-a-page-class)
47-
- [Utility Modules](#utility-modules)
48-
- [1. Purpose of Utility Modules](#1-purpose-of-utility-modules)
49-
- [2. Example: Wait Utility](#2-example-wait-utility)
50-
- [3. Best Practices](#3-best-practices)
51-
- [4. Blueprint Utilities](#4-blueprint-utilities)
52-
- [Contributing](#contributing)
53-
- [Contacts](#contacts)
54-
- [Licence](#licence)
55-
56-
# Getting Started
57-
58-
## Prerequisites
59-
60-
Follow these steps to make sure your system is ready to run the BCSS test framework.
61-
62-
### 1. Install Python 3.11 or higher
18+
- [Origin of the Framework](#origin-of-the-framework)
19+
- [Table of Contents](#table-of-contents)
20+
- [Getting Started](#getting-started)
21+
- [Prerequisites](#prerequisites)
22+
- [1. Install Python 3.11 or higher](#1-install-python-311-or-higher)
23+
- [2. Set up a virtual environment (recommended)](#2-set-up-a-virtual-environment-recommended)
24+
- [First Create the virtual environment](#first-create-the-virtual-environment)
25+
- [Next Activate the virtual environment](#next-activate-the-virtual-environment)
26+
- [3. Install Playwright browser binaries](#3-install-playwright-browser-binaries)
27+
- [Installation \& Configuration](#installation--configuration)
28+
- [1. Install Dependencies](#1-install-dependencies)
29+
- [2. Environment Variables](#2-environment-variables)
30+
- [3. Test Configuration](#3-test-configuration)
31+
- [Running Tests](#running-tests)
32+
- [1. Basic Test Execution](#1-basic-test-execution)
33+
- [2. Test Filtering](#2-test-filtering)
34+
- [3. Viewing Trace Files](#3-viewing-trace-files)
35+
- [Test Structure and Conventions](#test-structure-and-conventions)
36+
- [1. File Organization](#1-file-organization)
37+
- [2. Naming Conventions](#2-naming-conventions)
38+
- [3. Test Function Anatomy](#3-test-function-anatomy)
39+
- [4. Markers and Tags](#4-markers-and-tags)
40+
- [5. Skipping and Expected Failures](#5-skipping-and-expected-failures)
41+
- [Page Object Model (POM) Guidelines](#page-object-model-pom-guidelines)
42+
- [1. What is a POM?](#1-what-is-a-pom)
43+
- [2. Location and Structure](#2-location-and-structure)
44+
- [3. Naming Convention](#3-naming-convention)
45+
- [4. Anatomy of a Page Class](#4-anatomy-of-a-page-class)
46+
- [Utility Modules](#utility-modules)
47+
- [1. Purpose of Utility Modules](#1-purpose-of-utility-modules)
48+
- [2. Example: Wait Utility](#2-example-wait-utility)
49+
- [3. Best Practices](#3-best-practices)
50+
- [4. Blueprint Utilities](#4-blueprint-utilities)
51+
- [Contributing](#contributing)
52+
- [Contacts](#contacts)
53+
- [Licence](#licence)
54+
55+
## Getting Started
56+
57+
### Prerequisites
58+
59+
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
6362

6463
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.
6564

6665
To check if Python is already installed, open a terminal or command prompt and run:
6766

6867
`python --version`
6968

70-
### 2. Set up a virtual environment (recommended)
69+
#### 2. Set up a virtual environment (recommended)
7170

7271
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.
7372

7473
Note: If you are using an IDE such as Visual Studio Code or PyCharm, you will normally be prompted to do this automatically.
7574

76-
#### First Create the virtual environment
75+
##### First Create the virtual environment
7776

7877
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:
7978

8079
`python -m venv .venv`
8180

8281
This creates a folder called .venv that contains a clean Python environment just for this project.
8382

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:
8584

8685
`python3 -m venv .venv`
8786

88-
#### Next Activate the virtual environment
87+
##### Next Activate the virtual environment
8988

9089
This step tells your terminal to use the Python version and packages inside .venv.
9190

@@ -103,17 +102,17 @@ On macOS/Linux:
103102

104103
Once activated, your terminal will show the virtual environment name (e.g. (.venv)), indicating you're working inside it.
105104

106-
### 3. Install Playwright browser binaries
105+
#### 3. Install Playwright browser binaries
107106

108107
Playwright uses real browsers to run tests. You’ll need to install these browser binaries once by running:
109108

110109
`playwright install`
111110

112111
This downloads the necessary versions of Chromium, Firefox, and WebKit so tests can run across different browser types.
113112

114-
## Installation & Configuration
113+
### Installation & Configuration
115114

116-
### 1. Install Dependencies
115+
#### 1. Install Dependencies
117116

118117
Before configuring anything, make sure all required packages are installed by running:
119118

@@ -126,21 +125,21 @@ This installs all Python dependencies listed in the `requirements.txt` file, inc
126125

127126
Note: If you're using a virtual environment (recommended), activate it before running the install command (see previous steps).
128127

129-
### 2. Environment Variables
128+
#### 2. Environment Variables
130129

131130
Create a `.env` file in the project root to store sensitive configuration values like credentials, URLs, or feature flags. Example:
132131

133-
```
132+
```Bash
134133
BASE_URL=https://bcss.example.com
135134
USERNAME=test_user
136135
PASSWORD=secure_password123
137136
```
138137

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.
140139
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.
142141

143-
### 3. Test Configuration
142+
#### 3. Test Configuration
144143

145144
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):
146145

@@ -149,9 +148,9 @@ You can test the configuration has worked by running our example tests, which ca
149148
Alternatively if you are using Visual Studio Code as your IDE, we have pre-configured this project to work with the
150149
[Testing functionality](https://code.visualstudio.com/docs/editor/testing) so the example tests should be discovered automatically.
151150

152-
## Running Tests
151+
### Running Tests
153152

154-
### 1. Basic Test Execution
153+
#### 1. Basic Test Execution
155154

156155
To run all tests with tracing enabled:
157156

@@ -163,7 +162,7 @@ To run a specific test file:
163162

164163
Tracing captures detailed information about each test run, including browser actions, network requests, and DOM snapshots.
165164

166-
### 2. Test Filtering
165+
#### 2. Test Filtering
167166

168167
Use markers or keywords to run subsets of tests:
169168

@@ -174,7 +173,7 @@ You can combine flags like `-v (verbose)` and `--maxfail=1` to control output an
174173

175174
`pytest -v --maxfail=1 --tracing on`
176175

177-
### 3. Viewing Trace Files
176+
#### 3. Viewing Trace Files
178177

179178
After running tests with tracing enabled, trace files are saved in the test-results folder.
180179

@@ -188,9 +187,9 @@ Use the interactive viewer to explore browser actions, network activity, and DOM
188187

189188
This is especially useful for debugging failed tests or understanding complex UI flows.
190189

191-
## Test Structure and Conventions
190+
### Test Structure and Conventions
192191

193-
### 1. File Organization
192+
#### 1. File Organization
194193

195194
All tests are located in the tests/ directory.
196195

@@ -200,7 +199,7 @@ Each feature or module has its own test file, e.g.:
200199

201200
`test_user_profile.py`
202201

203-
### 2. Naming Conventions
202+
#### 2. Naming Conventions
204203

205204
Test files: test_<feature>.py
206205
Example: test_login_to_bcss.py
@@ -209,11 +208,11 @@ Page Object Models: <page>_page.py
209208
Example: login_failure_screen_page.py
210209

211210

212-
### 3. Test Function Anatomy
211+
#### 3. Test Function Anatomy
213212

214213
Each test typically follows this structure:
215214

216-
```python
215+
```Python
217216
def test_user_can_login(page):
218217
login_page = LoginPage(page)
219218
login_page.navigate()
@@ -222,16 +221,14 @@ def test_user_can_login(page):
222221
```
223222

224223
- Use Page Object Model (POM) for UI interactions
225-
226224
- Keep assertions clear and focused
225+
- Avoid hard coded waits - prefer expect() or Playwright’s built-in waiting mechanisms
227226

228-
- Avoid hardcoded waits - prefer expect() or Playwright’s built-in waiting mechanisms
229-
230-
### 4. Markers and Tags
227+
#### 4. Markers and Tags
231228

232229
Use @pytest.mark.<tag> to run a subset or tests as required:
233230

234-
```python
231+
```Python
235232
@pytest.mark.smoke
236233
def test_basic_login(page):
237234
```
@@ -245,11 +242,11 @@ smoke: quick validation of core functionality
245242
regression: full suite for release validation
246243
slow: long-running tests
247244

248-
### 5. Skipping and Expected Failures
245+
#### 5. Skipping and Expected Failures
249246

250247
Use Pytest decorators to manage test behavior:
251248

252-
```python
249+
```Python
253250
@pytest.mark.skip(reason="Feature not implemented yet")
254251
def test_future_feature(page):
255252

@@ -258,22 +255,23 @@ def test_future_feature(page):
258255
def test_login_with_invalid_credentials(page):
259256
```
260257

261-
## Page Object Model (POM) Guidelines
258+
### Page Object Model (POM) Guidelines
259+
260+
#### 1. What is a POM?
262261

263-
### 1. What is a POM?
264262
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.
265263

266264
Instead of writing raw selectors and actions in your test, you use methods from a page class:
267265

268-
```python
266+
```Python
269267
def test_user_can_login(page):
270268
login_page = LoginPage(page)
271269
login_page.navigate()
272270
login_page.login("[email protected]", "securepassword")
273271
assert login_page.is_logged_in()
274272
```
275273

276-
### 2. Location and Structure
274+
#### 2. Location and Structure
277275

278276
All POMs are stored in the pages/ directory.
279277

@@ -283,14 +281,14 @@ Each file represents a single page or component, for example:
283281
- dashboard_page.py
284282
- user_profile_page.py
285283

286-
### 3. Naming Convention
284+
#### 3. Naming Convention
287285

288286
- Class names: LoginPage, DashboardPage, etc.
289287
- File names: lowercase with underscores, matching the class name (e.g. login_page.py)
290288

291-
### 4. Anatomy of a Page Class
289+
#### 4. Anatomy of a Page Class
292290

293-
```python
291+
```Python
294292
class LoginPage:
295293
def __init__(self, page):
296294
self.page = page
@@ -310,19 +308,19 @@ class LoginPage:
310308
return self.page.locator("text=Welcome").is_visible()
311309
```
312310

313-
## Utility Modules
311+
### Utility Modules
314312

315313
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).
316314

317-
### 1. Purpose of Utility Modules
315+
#### 1. Purpose of Utility Modules
318316

319317
- Handle reusable actions (e.g. login, file uploads, date pickers)
320318
- Provide custom assertions or wait conditions
321319
- Manage test data generation or environment setup
322320

323-
### 2. Example: Wait Utility
321+
#### 2. Example: Wait Utility
324322

325-
```python
323+
```Python
326324
# utils/wait_utils.py
327325

328326
from playwright.sync_api import expect
@@ -331,14 +329,14 @@ def wait_for_element(page, selector, timeout=5000):
331329
expect(page.locator(selector)).to_be_visible(timeout=timeout)
332330
```
333331

334-
### 3. Best Practices
332+
#### 3. Best Practices
335333

336334
- Keep utilities modular and single-purpose.
337-
- Avoid hardcoding valuesuse config files or environment variables.
335+
- Avoid hard coding values - use configuration files or environment variables.
338336
- Document each function with a short docstring.
339337
- Use type hints for clarity and IDE support.
340338

341-
### 4. Blueprint Utilities
339+
#### 4. Blueprint Utilities
342340

343341
This blueprint provides the following utility classes, that can be used to aid in testing:
344342

@@ -349,17 +347,17 @@ This blueprint provides the following utility classes, that can be used to aid i
349347
| [NHSNumberTools](./docs/utility-guides/NHSNumberTools.md) | Basic tools for working with NHS numbers. |
350348
| [User Tools](./docs/utility-guides/UserTools.md) | Basic user management tool. |
351349

352-
## Contributing
350+
### Contributing
353351

354352
Further guidance on contributing to this project can be found in our [contribution](./CONTRIBUTING.md) page.
355353

356-
## Contacts
354+
### Contacts
357355

358356
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.
359357

360358
If you have any general queries regarding this blueprint, please contact [[email protected]](mailto:[email protected]).
361359

362-
## Licence
360+
### Licence
363361

364362
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.
365363

0 commit comments

Comments
 (0)