diff --git a/LICENCE.md b/LICENCE.md index ed56eb21..02174c4c 100644 --- a/LICENCE.md +++ b/LICENCE.md @@ -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 diff --git a/README.md b/README.md index fc644e05..adb260bb 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/tests/test_example.py b/tests/test_example.py index faa5167a..a6b86845 100644 --- a/tests/test_example.py +++ b/tests/test_example.py @@ -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") @@ -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")