Skip to content

Commit be8e8ff

Browse files
adrianoaru-nhsAndyg79
authored andcommitted
Feature/bcss 20517 dynamic css locators (#71)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> Adding a new util to dynamically get input / select locators ## Context <!-- Why is this change required? What problem does it solve? --> reduces the clutter of locators in the investigation dataset POM ## 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. --> - [x] I am familiar with the [contributing guidelines](https://github.com/nhs-england-tools/playwright-python-blueprint/blob/main/CONTRIBUTING.md) - [x] I have followed the code style of the project - [x] I have added tests to cover my changes (where appropriate) - [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 bbe44a9 commit be8e8ff

File tree

4 files changed

+296
-474
lines changed

4 files changed

+296
-474
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Utility Guide: Dataset Field Utility
2+
3+
The Dataset Field utility allows for selecting different locators dynamically.<br>
4+
For example, on the investigation dataset, if we want to select the input locator for the `Start of intubation time` field, we can do this by providing the utility with the name of the field
5+
6+
DatasetFieldUtil(page).populate_input_locator_for_field(
7+
"Start of intubation time", "09:00"
8+
)
9+
10+
## Table of Contents
11+
12+
- [Utility Guide: Dataset Field Utility](#utility-guide-dataset-field-utility)
13+
- [Table of Contents](#table-of-contents)
14+
- [Using the DatasetFieldUtil class](#using-the-datasetfieldutil-class)
15+
- [Required Args](#required-args)
16+
- [How to use this method](#how-to-use-this-method)
17+
18+
## Using the DatasetFieldUtil class
19+
20+
You can initialise the DatasetFieldUtil class by using the following code in your test file:
21+
22+
from utils.dataset_field_util import DatasetFieldUtil
23+
24+
This will allow you to use the following methods:
25+
26+
1. populate_input_locator_for_field
27+
1. This will allow you to populate the field next to the given text where the type is `input`
28+
2. populate_select_locator_for_field
29+
1. This will allow you to populate the field next to the given text where the type is `select`
30+
3. populate_input_locator_for_field_inside_div
31+
1. This will allow you to populate the field next to the given text where the type is `input`, and inside of a specified container
32+
4. populate_select_locator_for_field_inside_div
33+
1. This will allow you to populate the field next to the given text where the type is `select`, and inside of a specified container
34+
35+
### Required Args
36+
37+
`populate_input_locator_for_field` / `populate_select_locator_for_field`
38+
39+
- text:
40+
- Type: `str`
41+
- The text of the element you want to interact with.
42+
- value/option:
43+
- Type: `str`
44+
- The value or option you want to input / select (depending on what method is called)
45+
46+
`populate_input_locator_for_field_inside_div` / `populate_select_locator_for_field_inside_div`
47+
48+
- text:
49+
- Type: `str`
50+
- The text of the element you want to interact with.
51+
- div:
52+
- Type: `str`
53+
- The ID of the container that the element belongs in.
54+
- value/option:
55+
- Type: `str`
56+
- The value or option you want to input / select (depending on what method is called)
57+
58+
### How to use this method
59+
60+
To use this method simply import the DatasetFieldUtil class and call one of the methods, providing the necessary arguments.<br>
61+
The example below is using options that can be imported from `pages.datasets.investigation_dataset_page`
62+
63+
from utils.dataset_field_util import DatasetFieldUtil
64+
from pages.datasets.investigation_dataset_page import (
65+
InsufflationOptions,
66+
PolypClassificationOptions,
67+
)
68+
69+
# populate_input_locator_for_field
70+
DatasetFieldUtil(page).populate_input_locator_for_field(
71+
"End time of procedure", "09:30"
72+
)
73+
74+
# populate_select_locator_for_field
75+
DatasetFieldUtil(page).populate_select_locator_for_field(
76+
"Insufflation", InsufflationOptions.AIR
77+
)
78+
79+
# populate_input_locator_for_field_inside_div
80+
DatasetFieldUtil(page).populate_input_locator_for_field_inside_div(
81+
"Estimate of whole polyp size", "divPolypNumber1Section", "15"
82+
)
83+
84+
# populate_select_locator_for_field_inside_div
85+
DatasetFieldUtil(page).populate_select_locator_for_field_inside_div(
86+
"Classification", "divPolypNumber1Section", PolypClassificationOptions.LS
87+
)

0 commit comments

Comments
 (0)