Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENCE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT Licence

Copyright (c) 2024 Crown Copyright NHS England.
Copyright (c) 2025 Crown Copyright NHS England.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

[![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)

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.
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/).

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](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.**
> NOTE: This project is currently under initial development so isn't finalised, but should work if you want to experiment with Playwright Python.

## Table of Contents

Expand Down
27 changes: 17 additions & 10 deletions tests/test_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,37 @@
from playwright.sync_api import Page, expect


@pytest.fixture(autouse=True)
def initial_navigation(page: Page) -> None:
'''
This fixture (or hook) is used for each test in this file to navigate to this repository before
each test, to reduce the need for repeated code within the tests directly.

This specific fixture has been designated to run for every test by setting autouse=True.
'''

# Navigate to page
page.goto("https://github.com/nhs-england-tools/playwright-python-blueprint")


@pytest.mark.example
def test_basic_example(page: Page) -> None:
'''
This test demonstrates how to quickly get started using Playwright Python.
This test demonstrates how to quickly get started using Playwright Python, which runs using pytest.

This example starts with @pytest.mark.example, which indicates this test has been tagged
with the term "example", to demonstrate how tests can be independently tagged.

When running via the command line, Playwright automatically instantiates certain objects
When running using the pytest command, Playwright automatically instantiates certain objects
available for use, including the Page object (which is how Playwright interacts with the
system under test).

This test does the following:
1) Navigates to this repository
1) Navigates to this repository (via the initial_navigation fixture above)
2) Asserts that the README contents rendered by GitHub contains the text "Playwright Python Blueprint"
3) Asserts that the main section of the page contains the topic label "playwright-python"
'''

# Navigate to page
page.goto("https://github.com/nhs-england-tools/playwright-python-blueprint")

# Assert repo text is present
expect(page.get_by_role("article")).to_contain_text("Playwright Python Blueprint")

Expand All @@ -52,15 +62,12 @@ def test_textbox_example(page: Page) -> None:
assertion).

This test does the following:
1) Navigates to this repository
1) Navigates to this repository (via the initial_navigation fixture above)
2) Uses the "Go to file" textbox and searches for this file, "text_example.py"
3) Selects the label for the dropdown element presented for the search results and clicks
4) Asserts that the filename for the now selected file is "test_example.py"
"""

# Navigate to page
page.goto("https://github.com/nhs-england-tools/playwright-python-blueprint")

# Select the "Go to file" textbox and search for this file
page.get_by_placeholder("Go to file").fill("test_example.py")

Expand Down
Loading