Skip to content

Commit e55f08b

Browse files
README Update (#14)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> This initially populates the README with information that is relevant to getting started with this project. ## Context <!-- Why is this change required? What problem does it solve? --> The initial information copied from the template was confusing and didn't actually do anything with Playwright. ## Type of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply. --> - [x] Refactoring (non-breaking change) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would change existing functionality) - [ ] Bug fix (non-breaking change which fixes an issue) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [ ] I am familiar with the [contributing guidelines](../docs/CONTRIBUTING.md) - [x] I have followed the code style of the project - [ ] I have added tests to cover my changes - [x] I have updated the documentation accordingly - [ ] This PR is a result of pair or mob programming --- ## Sensitive Information Declaration To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including [PII (Personal Identifiable Information) / PID (Personal Identifiable Data)](https://digital.nhs.uk/data-and-information/keeping-data-safe-and-benefitting-the-public) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter. - [x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
1 parent 4c788cd commit e55f08b

File tree

6 files changed

+38
-79
lines changed

6 files changed

+38
-79
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) 2023 Crown Copyright NHS England.
3+
Copyright (c) 2024 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: 30 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,78 @@
11
# Playwright Python Blueprint
22

3-
[![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/repository-template/actions/workflows/cicd-1-pull-request.yaml)
4-
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=repository-template&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=repository-template)
3+
[![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)
54

65
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.
76

87
NOTE: This project is currently under initial development.
98

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 at your own risk.**
10+
1011
## Table of Contents
1112

1213
- [Playwright Python Blueprint](#playwright-python-blueprint)
1314
- [Table of Contents](#table-of-contents)
1415
- [Setup](#setup)
1516
- [Prerequisites](#prerequisites)
1617
- [Configuration](#configuration)
17-
- [Usage](#usage)
18-
- [Testing](#testing)
19-
- [Design](#design)
20-
- [Diagrams](#diagrams)
21-
- [Modularity](#modularity)
22-
- [Contributing](#contributing)
18+
- [Getting Started](#getting-started)
2319
- [Contacts](#contacts)
2420
- [Licence](#licence)
2521

2622
## Setup
2723

28-
By including preferably a one-liner or if necessary a set of clear CLI instructions we improve user experience. This should be a frictionless installation process that works on various operating systems (macOS, Linux, Windows WSL) and handles all the dependencies.
29-
30-
Clone the repository
24+
You can clone this whole repository using the code below:
3125

3226
```shell
33-
git clone https://github.com/nhs-england-tools/repository-template.git
34-
cd nhs-england-tools/repository-template
27+
git clone https://github.com/nhs-england-tools/playwright-python-blueprint.git
3528
```
3629

37-
### Prerequisites
38-
39-
The following software packages, or their equivalents, are expected to be installed and configured:
30+
The code for actually working in Playwright is contained in the blueprint directory, so it's best to do the following to move straight into that working directory:
4031

41-
- [Docker](https://www.docker.com/) container runtime or a compatible tool, e.g. [Podman](https://podman.io/),
42-
- [asdf](https://asdf-vm.com/) version manager,
43-
- [GNU make](https://www.gnu.org/software/make/) 3.82 or later,
32+
```shell
33+
cd nhs-england-tools/playwright-python-blueprint/blueprint
34+
```
4435

45-
> [!NOTE]<br>
46-
> The version of GNU make available by default on macOS is earlier than 3.82. You will need to upgrade it or certain `make` tasks will fail. On macOS, you will need [Homebrew](https://brew.sh/) installed, then to install `make`, like so:
47-
>
48-
> ```shell
49-
> brew install make
50-
> ```
51-
>
52-
> You will then see instructions to fix your [`$PATH`](https://github.com/nhs-england-tools/dotfiles/blob/main/dot_path.tmpl) variable to make the newly installed version available. If you are using [dotfiles](https://github.com/nhs-england-tools/dotfiles), this is all done for you.
36+
### Prerequisites
5337

54-
- [GNU sed](https://www.gnu.org/software/sed/) and [GNU grep](https://www.gnu.org/software/grep/) are required for the scripted command-line output processing,
55-
- [GNU coreutils](https://www.gnu.org/software/coreutils/) and [GNU binutils](https://www.gnu.org/software/binutils/) may be required to build dependencies like Python, which may need to be compiled during installation,
38+
To utilise the blueprint code, you will need to have the following installed:
5639

57-
> [!NOTE]<br>
58-
> For macOS users, installation of the GNU toolchain has been scripted and automated as part of the `dotfiles` project. Please see this [script](https://github.com/nhs-england-tools/dotfiles/blob/main/assets/20-install-base-packages.macos.sh) for details.
40+
- [Python](https://www.python.org/downloads/) 3.12 or greater
5941

60-
- [Python](https://www.python.org/) required to run Git hooks,
61-
- [`jq`](https://jqlang.github.io/jq/) a lightweight and flexible command-line JSON processor.
42+
Whilst not required to get started, you may also want to [configure a Python virtual environment for your project](https://docs.python.org/3/library/venv.html) before proceeding with
43+
the configuration. If you are using an IDE such as Visual Studio Code or PyCharm, you will normally be prompted to do this automatically.
6244

6345
### Configuration
6446

65-
Installation and configuration of the toolchain dependencies
47+
To get started using Playwright and with the examples provided, use the following commands:
6648

6749
```shell
68-
make config
50+
pip install -r requirements.txt
51+
playwright install --with-deps
6952
```
7053

71-
## Usage
72-
73-
After a successful installation, provide an informative example of how this project can be used. Additional code snippets, screenshots and demos work well in this space. You may also link to the other documentation resources, e.g. the [User Guide](./docs/user-guide.md) to demonstrate more use cases and to show more features.
54+
This will install all the necessary packages for executing Playwright tests, and install Playwright ready for use by the framework. You can test the configuration
55+
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
56+
so you can see the browser execution):
7457

75-
### Testing
76-
77-
There are `make` tasks for you to configure to run your tests. Run `make test` to see how they work. You should be able to use the same entry points for local development as in your CI pipeline.
78-
79-
## Design
80-
81-
### Diagrams
82-
83-
The [C4 model](https://c4model.com/) is a simple and intuitive way to create software architecture diagrams that are clear, consistent, scalable and most importantly collaborative. This should result in documenting all the system interfaces, external dependencies and integration points.
84-
85-
![Repository Template](./docs/diagrams/Repository_Template_GitHub_Generic.png)
86-
87-
The source for diagrams should be in Git for change control and review purposes. Recommendations are [draw.io](https://app.diagrams.net/) (example above in [docs](.docs/diagrams/) folder) and [Mermaids](https://github.com/mermaid-js/mermaid). Here is an example Mermaids sequence diagram:
88-
89-
```mermaid
90-
sequenceDiagram
91-
User->>+Service: GET /users?params=...
92-
Service->>Service: auth request
93-
Service->>Database: get all users
94-
Database-->>Service: list of users
95-
Service->>Service: filter users
96-
Service-->>-User: list[User]
58+
```shell
59+
pytest --tracing on --headed
9760
```
9861

99-
### Modularity
62+
## Getting Started
10063

101-
Most of the projects are built with customisability and extendability in mind. At a minimum, this can be achieved by implementing service level configuration options and settings. The intention of this section is to show how this can be used. If the system processes data, you could mention here for example how the input is prepared for testing - anonymised, synthetic or live data.
64+
> NOTE: This section is currently under development and requires further work, so links to pages within this repository may not be very useful at this stage.
10265
103-
## Contributing
66+
Once you've confirmed your installation is working, please take a look at the following guides on getting started with Playwright Python.
10467

105-
Describe or link templates on how to raise an issue, feature request or make a contribution to the codebase. Reference the other documentation files, like
68+
1. [Understanding Playwright Python](./docs/getting-started/1_Understanding_Playwright_Python.md)
69+
2. [Blueprint File Breakdown](./docs/getting-started/2_Blueprint_File_Breakdown.md)
10670

107-
- Environment setup for contribution, i.e. `CONTRIBUTING.md`
108-
- Coding standards, branching, linting, practices for development and testing
109-
- Release process, versioning, changelog
110-
- Backlog, board, roadmap, ways of working
111-
- High-level requirements, guiding principles, decision records, etc.
71+
For additional reading and guidance on writing tests, we also recommend reviewing the [Playwright Python documentation](https://playwright.dev/python/docs/writing-tests).
11272

11373
## Contacts
11474

115-
Provide a way to contact the owners of this project. It can be a team, an individual or information on the means of getting in touch via active communication channels, e.g. opening a GitHub discussion, raising an issue, etc.
75+
If you have any queries regarding this blueprint, please contact [[email protected]](mailto:[email protected]).
11676

11777
## Licence
11878

blueprint/pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ addopts =
77
--json-report
88
--json-report-file=test-results/results.json
99
--json-report-omit=collectors
10+
--tracing=retain-on-failure
1011
markers =
1112
example: tests used for example purposes
1213
branch: tests designed to run at a branch level

blueprint/tests/test_example.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ def test_basic_example(page: Page) -> None:
2525
2626
This test does the following:
2727
1) Navigates to this repository
28-
2) Asserts that the README contents rendered by GitHub includes the text "Playwright Python Blueprint"
29-
3) Clicks the MIT license link
30-
4) Asserts that the LICENCE contents rendered by GitHub includes the text "MIT Licence"
28+
2) Asserts that the README contents rendered by GitHub contains the text "Playwright Python Blueprint"
29+
3) Asserts that the main section of the page contains the topic label "playwright-python"
3130
'''
3231

3332
# Navigate to page
@@ -36,11 +35,8 @@ def test_basic_example(page: Page) -> None:
3635
# Assert repo text is present
3736
expect(page.get_by_role("article")).to_contain_text("Playwright Python Blueprint")
3837

39-
# Click license link
40-
page.get_by_role("link", name="MIT license", exact=True).click()
41-
42-
# Assert license text
43-
expect(page.get_by_role("article")).to_contain_text("MIT Licence")
38+
# Assert the page loaded is the playwright-python topic page
39+
expect(page.get_by_role("main")).to_contain_text("playwright-python")
4440

4541

4642
@pytest.mark.example
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Getting Started #1: Understanding Playwright Python
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Getting Started #2: Blueprint File Breakdown

0 commit comments

Comments
 (0)