Skip to content

Commit 25057fe

Browse files
Merge branch 'nhs-england-tools:main' into main
2 parents ef3931d + 7cfe245 commit 25057fe

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

LICENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT Licence
22

3-
Copyright (c) 2024 Crown Copyright NHS England.
3+
Copyright (c) 2025 Crown Copyright NHS England.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
[![CI/CD Pull Request](https://github.com/nhs-england-tools/repository-template/actions/workflows/cicd-1-pull-request.yaml/badge.svg)](https://github.com/nhs-england-tools/playwright-python-blueprint/actions/workflows/cicd-1-pull-request.yaml)
44

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.
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. Playwright is the current mainstream UI testing tool for NHS England, as outlined on the [NHS England Tech Radar](https://radar.engineering.england.nhs.uk/).
66

7-
NOTE: This project is currently under initial development so isn't finalised, but should work if you want to experiment with Playwright Python.
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 currently at your own risk.**
7+
> NOTE: This project is currently under initial development so isn't finalised, but should work if you want to experiment with Playwright Python.
108
119
## Table of Contents
1210

tests/test_example.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,37 @@
1111
from playwright.sync_api import Page, expect
1212

1313

14+
@pytest.fixture(autouse=True)
15+
def initial_navigation(page: Page) -> None:
16+
'''
17+
This fixture (or hook) is used for each test in this file to navigate to this repository before
18+
each test, to reduce the need for repeated code within the tests directly.
19+
20+
This specific fixture has been designated to run for every test by setting autouse=True.
21+
'''
22+
23+
# Navigate to page
24+
page.goto("https://github.com/nhs-england-tools/playwright-python-blueprint")
25+
26+
1427
@pytest.mark.example
1528
def test_basic_example(page: Page) -> None:
1629
'''
17-
This test demonstrates how to quickly get started using Playwright Python.
30+
This test demonstrates how to quickly get started using Playwright Python, which runs using pytest.
1831
1932
This example starts with @pytest.mark.example, which indicates this test has been tagged
2033
with the term "example", to demonstrate how tests can be independently tagged.
2134
22-
When running via the command line, Playwright automatically instantiates certain objects
35+
When running using the pytest command, Playwright automatically instantiates certain objects
2336
available for use, including the Page object (which is how Playwright interacts with the
2437
system under test).
2538
2639
This test does the following:
27-
1) Navigates to this repository
40+
1) Navigates to this repository (via the initial_navigation fixture above)
2841
2) Asserts that the README contents rendered by GitHub contains the text "Playwright Python Blueprint"
2942
3) Asserts that the main section of the page contains the topic label "playwright-python"
3043
'''
3144

32-
# Navigate to page
33-
page.goto("https://github.com/nhs-england-tools/playwright-python-blueprint")
34-
3545
# Assert repo text is present
3646
expect(page.get_by_role("article")).to_contain_text("Playwright Python Blueprint")
3747

@@ -52,15 +62,12 @@ def test_textbox_example(page: Page) -> None:
5262
assertion).
5363
5464
This test does the following:
55-
1) Navigates to this repository
65+
1) Navigates to this repository (via the initial_navigation fixture above)
5666
2) Uses the "Go to file" textbox and searches for this file, "text_example.py"
5767
3) Selects the label for the dropdown element presented for the search results and clicks
5868
4) Asserts that the filename for the now selected file is "test_example.py"
5969
"""
6070

61-
# Navigate to page
62-
page.goto("https://github.com/nhs-england-tools/playwright-python-blueprint")
63-
6471
# Select the "Go to file" textbox and search for this file
6572
page.get_by_placeholder("Go to file").fill("test_example.py")
6673

0 commit comments

Comments
 (0)