Skip to content

Commit

Permalink
Finalised tests and updated readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed Jun 6, 2024
1 parent 147d614 commit cd169d1
Show file tree
Hide file tree
Showing 20 changed files with 344 additions and 121 deletions.
173 changes: 173 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@ Make use of this repository template to expedite your project setup and enhance
- [Contacts](#contacts)
- [Licence](#licence)
- [Setup Make in windows](#setup-make-in-windows)
- [WSL Set Up](#wsl-set-up)
- [Windows WSL Installation](#windows-wsl-installation)
- [Set up Visual Code to develop with WSL (optional)](#set-up-visual-code-to-develop-with-wsl-optional)
- [Install pytest](#install-pytest)
- [Git commits](#git-commits)
- [RAVS Playwright Pytest BDD Tests](#ravs-playwright-pytest-bdd-tests)
- [Features](#features)
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites-1)
- [Installation](#installation)
- [Docker](#docker)
- [Build Docker Image](#build-docker-image)
- [Run Docker Container](#run-docker-container)
- [Usage](#usage-1)
- [Configuration](#configuration-1)
- [Folder Structure](#folder-structure)
- [Test Run Report](#test-run-report)
- [Contributing](#contributing-1)
- [License](#license)

## Setup

Expand Down Expand Up @@ -122,4 +141,158 @@ Then install make using

```choco install make```

After installing make

```make githook-run```

# WSL Set Up

## Windows WSL Installation

[Install Linux on Windows with WSL](https://learn.microsoft.com/en-us/windows/wsl/install)

__Notes:__
- Unless otherwise specified, all commands are being run inside the Linux shell not Windows.
- Before we get started, Windows WSL users may wish to run this command (in the Linux shell) to set the default path to home. Alternatively set the path in windows terminal - this will allow multiple profiles:

```
echo -e '\n# Set default path to linux home directory\ncd ~' >> ~/.bashrc
source ~/.bashrc
```

- The WSL Ubuntu version might need openssl package to be updated, so run:

```
sudo apt upgrade && sudo apt update
```

(An out of date version of openssl will create problems with the self-signed certificate scripts.)

## Set up Visual Code to develop with WSL (optional)

[Configure Visual Studio Code to develop in WSL](VSCODE.md)

## Install pytest

```bash
pip install -U pytest
sudo apt-get update
sudo apt-get install jq
```
## Git commits

In order to make git commits to this repo, you need to use the following command in terminal

```bash
wsl
```
Need to configure git credentials in wsl and this is the command to make commits to the repo

```bash
PRE_COMMIT_ALLOW_NO_CONFIG=1 git commit -m "commit message"
```

# RAVS Playwright Pytest BDD Tests

This is a project for setting up and running end-to-end tests using Playwright, Pytest, and the Behavior-Driven Development (BDD) approach. It utilizes the dependency injection design pattern to provide a flexible and modular testing framework. It provides a flexible and modular testing framework, allowing for easy integration into future projects.

## Features

- **Playwright**: A Python library for automating browsers based on the powerful Playwright toolset.
- **Pytest**: A testing framework that makes it easy to write simple and scalable tests.
- **Behavior-Driven Development (BDD)**: A methodology for writing tests in simple, natural language constructs, making them more accessible to non-technical stakeholders.
- **Dependency Injection**: The project leverages the dependency injection design pattern to manage dependencies and promote code reusability and testability.

## Getting Started

### Prerequisites

- Python installed on your machine
- Pip package manager

### Installation

1. Clone this repository:

```bash
git clone [email protected]:NHSDigital/ravs-tests.git
```
2. Navigate to the project directory:

```bash
cd ravs-tests
```

3. Install dependencies:

```bash
pip install -r requirements.txt
```
## Docker

### Build Docker Image

Build the Docker image using the following command:

```bash
docker build -t your_docker_image_name -f Docker/tests.dockerfile .
```
### Run Docker Container

Run the Docker container using the following command:

```bash
docker run -it -p 5050:5050 \
-e RAVS_PASSWORD=$env:RAVS_PASSWORD \
-e HEADLESS_MODE="true" \
-e TEST_ENVIRONMENT="qa" \
-e BROWSER="chrome" \
-e DEVICE="iphone_12" \
-e MARKER="login" \
-e AGENTS=3 \
your_docker_image_name
```
Replace your_docker_image_name with the desired name for your Docker image. This command will run the Docker container with the specified environment variables, including the password, headless mode, test environment, browser, and device configuration.

### Usage

1. Write your feature files using Gherkin syntax in the `features` directory.
2. Implement your step definitions in the `steps` directory using Python.
3. Run the tests using the following command:

```bash
# For Windows
scoop install allure
# For Linux
apt-get update && apt-get install -y allure
# Set the password, headless mode, test environment, and browser variables and run the tests
$env:RAVS_PASSWORD = "YourPasswordHere"; $env:HEADLESS_MODE = "false"; $env:TEST_ENVIRONMENT= "qa"; $env:BROWSER= "chrome" tox
```
### Configuration

- Modify the `pytest.ini` file to configure Pytest options and plugins.
- Update the `tox.ini` file to define the test environments and configurations.

### Folder Structure
- features
- steps
- pages
- helpers
- pages
- Docker

### Test Run Report

The latest test run report can be found ([here](https://allure-report-ravs.netlify.app/#))

## Contributing

Contributions are welcome! If you have suggestions, improvements, or new features to add, feel free to open an issue or submit a pull request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

26 changes: 13 additions & 13 deletions features/record_a_vaccine_for_patient_with_nhs_number.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ Examples:
| index | nhs_number | site | care_model | eligibility | assess_date | consent | vaccination | vaccination_date | name | dob | address | chosen_vaccine | vaccine_type | batch_number | batch_expiry_date |
| 0 | 9693632109 | NEELIMA HOUSE | Vaccination Centre | yes | today | yes | yes | today | Bill GARTON | 23/6/1946 | 1 MOUNT AVENUE, BARTON-UPON-HUMBER, S HUMBERSIDE, DN18 5DW | COVID-19 | Comirnaty Original/Omicron BA.4-5 | SDYY2-12 | 19/10/2025 |
| 1 | 9693632109 | NEELIMA HOUSE | Vaccination Centre | yes | today | yes | yes | today-1 | Bill GARTON | 23/6/1946 | 1 MOUNT AVENUE, BARTON-UPON-HUMBER, S HUMBERSIDE, DN18 5DW | COVID-19 | Comirnaty Original/Omicron BA.4-5 | SDYY2-12B | 19/10/2025 |
| 2 | 9470040228 | FRAZER HOUSE | Hospital Hub | yes | today-1 | yes | yes | today | HERBERT HAAG | 14/12/1922 | 10 COASTAL ROAD, HEST BANK, LANCASTER, LA2 6HN | COVID-19 | Comirnaty 30 Omicron XBB.1.5 | SB12345-12A | 19/2/2026 |
| 2 | 9470040228 | NEELIMA HOUSE | Hospital Hub | yes | today-1 | yes | yes | today | HERBERT HAAG | 14/12/1922 | 10 COASTAL ROAD, HEST BANK, LANCASTER, LA2 6HN | COVID-19 | Comirnaty 30 Omicron XBB.1.5 | SB12345-12A | 19/2/2026 |
| 3 | 9470057589 | NEELIMA HOUSE | Care Home | yes | today-2 | yes | yes | today-1 | ROGER SEABORNE | 13/12/1922 | 10 ANN STREET, DALTON-IN-FURNESS, CUMBRIA, LA15 8BG | COVID-19 | Comirnaty 3 Omicron XBB.1.5 | SDYY2-13A | 19/10/2026 |
| 4 | 9472710255 | NEELIMA HOUSE | Home Of Housebound Patient | yes | today-3 | yes | yes | today-2 | DELICE PINKER | 10/11/1926 | HARDCRAGG HOUSE, HARDCRAGG WAY, GRANGE-OVER-SANDS, CUMBRIA, LA11 6BH | COVID-19 | Comirnaty 10 Omicron XBB.1.5 | SDYY2-14A | 19/10/2026 |
| 5 | 9473629885 | NEELIMA HOUSE | Off-site Outreach Event | yes | today-4 | yes | yes | today-3 | MARGIE PUCKEY | 27/5/1924 | MANSART COURT, 10 OLIVE SHAPLEY AVENUE, MANCHESTER, M20 6QB | COVID-19 | Spikevax XBB.1.5 | SDYY2-15A | 19/10/2026 |
| 6 | 9437540233 | FRAZER HOUSE | Vaccination Centre | yes | today -5 | yes | yes | today-2 | RANDY FOGDEN | 8/6/1961 | 10 ASHVILLE TERRACE, MANCHESTER, M40 9WG | COVID-19 | Spikevax XBB.1.5 | SDYY2-16A | 19/10/2026 |
| 6 | 9437540233 | NEELIMA HOUSE | Vaccination Centre | yes | today -5 | yes | yes | today-2 | RANDY FOGDEN | 8/6/1961 | 10 ASHVILLE TERRACE, MANCHESTER, M40 9WG | COVID-19 | Spikevax XBB.1.5 | SDYY2-16A | 19/10/2026 |
| 7 | 9474374228 | NEELIMA HOUSE | Hospital Hub | yes | today-6 | yes | yes | today-3 | ORINDA JUDD | 20/7/1963 | 2 RECTORY PADDOCK, HALTON, LANCASTER, LA2 6LL | COVID-19 | Spikevax XBB.1.5 | SDYY2-17A | 19/10/2026 |
| 8 | 9437580812 | NEELIMA HOUSE | Care Home | yes | today-7 | yes | yes | today-7 | INDIGO CATCHESIDE | 1/3/1959 | 12 CANBERRA STREET, MANCHESTER, M11 4WL | COVID-19 | Comirnaty Original/Omicron BA.4-5 | SDYY2-18A | 19/10/2026 |
| 9 | 9437599165 | NEELIMA HOUSE | Home Of Housebound Patient | yes | today-30 | yes | yes | today-30 | CAWRDAV BOBBETT | 21/7/1959 | 127 ALINORA CRESCENT, GORING-BY-SEA, WORTHING, W SUSSEX, BN12 4HN | COVID-19 | Comirnaty 30 Omicron XBB.1.5 | SDYY2-18B | 19/10/2026 |
| 10 | 9474335052 | NEELIMA HOUSE | Off-site Outreach Event | yes | today | yes | yes | today | AMERY PIGGOTT | 20/4/1968 | 10 CONNAUGHT ROAD, LANCASTER, LA1 4BQ | COVID-19 | Comirnaty 3 Omicron XBB.1.5 | SDYY2-18C | 19/10/2026 |
| 11 | 9437541817 | PAUL TOWERS | Vaccination Centre | yes | today | yes | yes | today | FLORINDA DUNNER | 27/3/1957 | 32 HOLLAND ROAD, MANCHESTER, M8 4NP | COVID-19 | Comirnaty 10 Omicron XBB.1.5 | SDYY2-18D | 19/10/2026 |
| 12 | 9437540233 | PAUL TOWERS | Hospital Hub | yes | today | yes | yes | today | RANDY FOGDEN | 8/6/1961 | 10 ASHVILLE TERRACE, MANCHESTER, M40 9WG | COVID-19 | Spikevax XBB.1.5 | SDYY2-18E | 19/10/2026 |
| 8 | 9474376638 | PAUL TOWERS | Care Home | yes | today | yes | yes | today | PHYLLIDA ZYLKO | 6/2/1968 | BELL FARM BUNGALOW, CATON GREEN, BROOKHOUSE, LANCASTER, LA2 9JG | Flu | Fluenz Tetra - LAIV | SDYY2-18F | 19/10/2026 |
| 9 | 9474405174 | PAUL TOWERS | Home Of Housebound Patient | yes | today | yes | yes | today | PHINEAS FAYLE | 4/9/1965 | 2 DIXON TERRACE, NETHER KELLET, CARNFORTH, LANCS, LA6 1EX | Flu | Fluenz Tetra - LAIV | SDYY2-19A | 19/10/2026 |
| 10 | 9474405174 | PAUL TOWERS | Off-site Outreach Event | yes | today | yes | yes | today| PHINEAS FAYLE | 4/9/1965 | 2 DIXON TERRACE, NETHER KELLET, CARNFORTH, LANCS, LA6 1EX | Flu | Quadrivalent Influenza vaccine - QIVe | SDYY2-14B | 19/10/2026 |
| 11 | 9450134391 | SCOTT HOSPITAL | Vaccination Centre | yes | today | yes | yes | today | MARIAN PIESSE | 17/7/1994 | 2 BIRCH STREET, LYTHAM ST. ANNES, LANCS, FY8 5DT | Flu | Quadrivalent Influvac sub - unit Tetra - QIVe | SDYY2-14C | 19/10/2026 |
| 12 | 9450140960 | SCOTT HOSPITAL | Hospital Hub | yes | today | yes | yes | today | DEANA GAMBLES | 5/9/1993 | 10 GRASMERE ROAD, LYTHAM ST. ANNES, LANCS, FY8 2HZ | Flu | Flucelvax Tetra - QIVc | SDYY2-20A | 19/10/2026 |
| 1 | 9450141444 | SCOTT HOSPITAL | Care Home | yes | today | yes | yes | today | BRANDIE DYBLE | 25/8/1992 | 49 BLACKPOOL ROAD NORTH, LYTHAM ST. ANNES, LANCS, FY8 3DF | Flu | Supemtek - QIVr | SDYY2-21A | 19/10/2026 |
| 2 | 9450141711 | SCOTT HOSPITAL | Home Of Housebound Patient | yes | today | yes | yes | today | KRISTIA SIDAWAY | 24/6/1992 | 41 BALTIMORE ROAD, LYTHAM ST. ANNES, LANCS, FY8 3NY | Flu | Fluad Tetra - aQIV | SDYY2-22A | 19/10/2026 |
| 3 | 9450144699 | SCOTT HOSPITAL | Off-site Outreach Event | yes | today | yes | yes | today-1 | HOPE TULLY | 10/1/1993 | 2 CHAPEL CLOSE, WESHAM, PRESTON, PR4 3HB | Flu | Cell-based Quadrivalent - QIVc | SDYY2-23A | 19/10/2026 |
| 4 | 9437541817 | FRAZER HOUSE | Off-site Outreach Event |yes | today | yes | yes | today | FLORINDA DUNNER | 27/3/1957 | 32 HOLLAND ROAD, MANCHESTER, M8 4NP | Flu | Adjuvanted Quadrivalent - aQIV | SDYY2-24A | 19/10/2026 |
| 11 | 9437541817 | ALBERT HOUSE | Vaccination Centre | yes | today | yes | yes | today | FLORINDA DUNNER | 27/3/1957 | 32 HOLLAND ROAD, MANCHESTER, M8 4NP | COVID-19 | Comirnaty 10 Omicron XBB.1.5 | SDYY2-18D | 19/10/2026 |
| 12 | 9437540233 | ALBERT HOUSE | Hospital Hub | yes | today | yes | yes | today | RANDY FOGDEN | 8/6/1961 | 10 ASHVILLE TERRACE, MANCHESTER, M40 9WG | COVID-19 | Spikevax XBB.1.5 | SDYY2-18E | 19/10/2026 |
| 8 | 9474376638 | ALBERT HOUSE | Care Home | yes | today | yes | yes | today | PHYLLIDA ZYLKO | 6/2/1968 | BELL FARM BUNGALOW, CATON GREEN, BROOKHOUSE, LANCASTER, LA2 9JG | Flu | Fluenz Tetra - LAIV | SDYY2-18F | 19/10/2026 |
| 9 | 9474405174 | ALBERT HOUSE | Home Of Housebound Patient | yes | today | yes | yes | today | PHINEAS FAYLE | 4/9/1965 | 2 DIXON TERRACE, NETHER KELLET, CARNFORTH, LANCS, LA6 1EX | Flu | Fluenz Tetra - LAIV | SDYY2-19A | 19/10/2026 |
| 10 | 9474405174 | ALBERT HOUSE | Off-site Outreach Event | yes | today | yes | yes | today| PHINEAS FAYLE | 4/9/1965 | 2 DIXON TERRACE, NETHER KELLET, CARNFORTH, LANCS, LA6 1EX | Flu | Quadrivalent Influenza vaccine - QIVe | SDYY2-14B | 19/10/2026 |
| 11 | 9450134391 | ALBERT HOUSE | Vaccination Centre | yes | today | yes | yes | today | MARIAN PIESSE | 17/7/1994 | 2 BIRCH STREET, LYTHAM ST. ANNES, LANCS, FY8 5DT | Flu | Quadrivalent Influvac sub - unit Tetra - QIVe | SDYY2-14C | 19/10/2026 |
| 12 | 9450140960 | ALBERT HOUSE | Hospital Hub | yes | today | yes | yes | today | DEANA GAMBLES | 5/9/1993 | 10 GRASMERE ROAD, LYTHAM ST. ANNES, LANCS, FY8 2HZ | Flu | Flucelvax Tetra - QIVc | SDYY2-20A | 19/10/2026 |
| 1 | 9450141444 | ALBERT HOUSE | Care Home | yes | today | yes | yes | today | BRANDIE DYBLE | 25/8/1992 | 49 BLACKPOOL ROAD NORTH, LYTHAM ST. ANNES, LANCS, FY8 3DF | Flu | Supemtek - QIVr | SDYY2-21A | 19/10/2026 |
| 2 | 9450141711 | ALBERT HOUSE | Home Of Housebound Patient | yes | today | yes | yes | today | KRISTIA SIDAWAY | 24/6/1992 | 41 BALTIMORE ROAD, LYTHAM ST. ANNES, LANCS, FY8 3NY | Flu | Fluad Tetra - aQIV | SDYY2-22A | 19/10/2026 |
| 3 | 9450144699 | ALBERT HOUSE | Off-site Outreach Event | yes | today | yes | yes | today-1 | HOPE TULLY | 10/1/1993 | 2 CHAPEL CLOSE, WESHAM, PRESTON, PR4 3HB | Flu | Cell-based Quadrivalent - QIVc | SDYY2-23A | 19/10/2026 |
| 4 | 9437541817 | NEELIMA HOUSE | Off-site Outreach Event |yes | today | yes | yes | today | FLORINDA DUNNER | 27/3/1957 | 32 HOLLAND ROAD, MANCHESTER, M8 4NP | Flu | Adjuvanted Quadrivalent - aQIV | SDYY2-24A | 19/10/2026 |
4 changes: 2 additions & 2 deletions helpers/playwrightHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ def navigate_to_url(self,url):
self.page.wait_for_load_state()


def wait_for_page_to_load(self, timeout=10):
def wait_for_page_to_load(self, timeout=1):
self.page.wait_for_selector('*')
self.page.wait_for_load_state('domcontentloaded', timeout=timeout * 1000)
self.page.wait_for_load_state('domcontentloaded', timeout=timeout * 100)

def find_elements(self, selector):
return self.page.query_selector_all(selector)
Expand Down
2 changes: 1 addition & 1 deletion init_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def load_config_from_env():
"headless_mode": os.environ.get("HEADLESS_MODE",""),
"browser": os.environ.get("BROWSER", "chrome"),
"device": os.environ.get("DEVICE", "iphone_12"),
"timeout_seconds": int(os.environ.get("TIMEOUT_SECONDS", 10)),
"timeout_seconds": int(os.environ.get("TIMEOUT_SECONDS", 3)),
"credentials": {
"ravs_password": os.environ.get("RAVS_PASSWORD", "")
}
Expand Down
22 changes: 3 additions & 19 deletions pages/add_vaccines_page.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from init_helpers import *
from test_data.get_values_from_models import get_flu_add_vaccine_checkbox_xpath, get_covid_add_vaccine_checkbox_xpath

ADD_VACCINE_BUTTON = ("//button[text()='Add vaccine']")
ADD_BATCHES_BUTTON = ("//button[text()='Add batches']")
Expand Down Expand Up @@ -46,32 +47,15 @@ def click_flu_vaccine_checkbox():
find_element_and_perform_action(FLU_VACCINE_CHECK_BOX, "click_checkbox")

def click_covid_vaccine_type_checkbox(vaccinetype):
xpath_map = {
"comirnaty original/omicron ba.4-5": "//input[@class='nhsuk-checkboxes__input' and @name='CovidVaccineIds' and @value='1']",
"comirnaty 30 omicron xbb.1.5": "//input[@class='nhsuk-checkboxes__input' and @name='CovidVaccineIds' and @value='2']",
"comirnaty 3 omicron xbb.1.5": "//input[@class='nhsuk-checkboxes__input' and @name='CovidVaccineIds' and @value='3']",
"comirnaty 10 omicron xbb.1.5": "//input[@class='nhsuk-checkboxes__input' and @name='CovidVaccineIds' and @value='4']",
"spikevax xbb.1.5": "//input[@class='nhsuk-checkboxes__input' and @name='CovidVaccineIds' and @value='5']"
}
element = xpath_map.get(vaccinetype.lower())
element = get_covid_add_vaccine_checkbox_xpath(vaccinetype.lower())
if element:
find_element_and_perform_action(element, "click_checkbox")
else:
print("Invalid vaccine type")


def click_flu_vaccine_type_checkbox(vaccinetype):
xpath_map = {
"fluenz tetra - laiv": "//input[@class='nhsuk-checkboxes__input' and @name='FluVaccineIds' and @value='6']",
"quadrivalent influenza vaccine - qive": "//input[@class='nhsuk-checkboxes__input' and @name='FluVaccineIds' and @value='7']",
"quadrivalent influvac sub - unit tetra - qive": "//input[@class='nhsuk-checkboxes__input' and @name='FluVaccineIds' and @value='8']",
"flucelvax tetra - qivc": "//input[@class='nhsuk-checkboxes__input' and @name='FluVaccineIds' and @value='9']",
"supemtek - qivr": "//input[@class='nhsuk-checkboxes__input' and @name='FluVaccineIds' and @value='10']",
"fluad tetra - aqiv": "//input[@class='nhsuk-checkboxes__input' and @name='FluVaccineIds' and @value='11']",
"cell-based quadrivalent - qivc": "//input[@class='nhsuk-radios__input' and @name='ConsentVaccineId' and @value='12']",
"adjuvanted quadrivalent - aqiv": "//input[@class='nhsuk-radios__input' and @name='ConsentVaccineId' and @value='13']"
}
element = xpath_map.get(vaccinetype.lower())
element = get_flu_add_vaccine_checkbox_xpath(vaccinetype.lower())
if element:
find_element_and_perform_action(element, "click_checkbox")
else:
Expand Down
Loading

0 comments on commit cd169d1

Please sign in to comment.