Skip to content

Commit 1e7f7bb

Browse files
Feature/bcss 20858 selenium to playwright datasets dimunutiverectalhyperplasticpolyp (#104)
<!-- markdownlint-disable-next-line first-line-heading --> ## Description <!-- Describe your changes in detail. --> Converting tests from selenium to playwright as per BCSS-20858 ## Context <!-- Why is this change required? What problem does it solve? --> Converting tests from selenium to playwright as per BCSS-20858 ## 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 9ebe171 commit 1e7f7bb

File tree

10 files changed

+1074
-483
lines changed

10 files changed

+1074
-483
lines changed

docs/utility-guides/InvestigationDataset.md

Lines changed: 226 additions & 118 deletions
Large diffs are not rendered by default.

pages/datasets/investigation_dataset_page.py

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
get_investigation_dataset_polyp_algorithm_size,
77
)
88
from typing import Optional
9+
import logging
910

1011

1112
class InvestigationDatasetsPage(BasePage):
@@ -15,6 +16,8 @@ def __init__(self, page: Page):
1516
super().__init__(page)
1617
self.page = page
1718

19+
self.add_intervention_string = "Add Intervention"
20+
1821
# Investigation datasets page locators
1922
self.site_lookup_link = self.page.locator("#UI_SITE_SELECT_LINK")
2023
self.practitioner_link = self.page.locator("#UI_SSP_PIO_SELECT_LINK")
@@ -47,11 +50,11 @@ def __init__(self, page: Page):
4750
self.show_failure_information_details = self.page.locator("#anchorFailure")
4851
self.add_polyp_button = self.page.get_by_role("button", name="Add Polyp")
4952
self.polyp1_add_intervention_button = self.page.get_by_role(
50-
"link", name="Add Intervention"
53+
"link", name=self.add_intervention_string
5154
)
5255
self.polyp2_add_intervention_button = self.page.locator(
5356
"#spanPolypInterventionLink2"
54-
).get_by_role("link", name="Add Intervention")
57+
).get_by_role("link", name=self.add_intervention_string)
5558
self.dataset_complete_checkbox = self.page.locator("#radDatasetCompleteYes")
5659
self.dataset_incomplete_checkbox = self.page.locator("#radDatasetCompleteNo")
5760
self.save_dataset_button = self.page.locator(
@@ -361,6 +364,21 @@ def select_polyp1_pathologist_option_index(self, option: int) -> None:
361364
option_elements.nth(option).wait_for(state="visible")
362365
self.click(option_elements.nth(option))
363366

367+
def select_loopup_option_index(self, option: int) -> None:
368+
"""
369+
This method is designed to select a lookup option by index.
370+
It clicks on the lookup link and selects the given option by index.
371+
372+
Args:
373+
option (int): The index of the option to select from the lookup options.
374+
"""
375+
select_locator = self.page.locator(self.visible_ui_results_string)
376+
select_locator.first.wait_for(state="visible")
377+
# Find all option elements inside the select and click the one at the given index
378+
option_elements = select_locator.first.locator("option")
379+
option_elements.nth(option).wait_for(state="visible")
380+
self.click(option_elements.nth(option))
381+
364382
def click_edit_dataset_button(self) -> None:
365383
"""
366384
This method is designed to click on the edit dataset button.
@@ -387,6 +405,10 @@ def assert_polyp_alogrithm_size(
387405
)
388406

389407
# Assert that the actual value matches the expected value
408+
logging.info(
409+
f"Checking Polyp {polyp_number} algorithm size: actual={actual_value}, expected={expected_value}"
410+
)
411+
390412
if actual_value is None or expected_value is None:
391413
assert (
392414
actual_value == expected_value
@@ -415,6 +437,10 @@ def assert_polyp_categrory(
415437
)
416438

417439
# Assert that the actual value matches the expected value
440+
logging.info(
441+
f"Checking Polyp {polyp_number} category: actual={actual_value}, expected={expected_value}"
442+
)
443+
418444
if actual_value is None or expected_value is None:
419445
assert (
420446
actual_value == expected_value
@@ -443,6 +469,20 @@ def get_dataset_id(self) -> int:
443469
dataset_id = -1
444470
return dataset_id
445471

472+
def click_polyp_add_intervention_button(self, polyp_number: int) -> None:
473+
"""
474+
Clicks the add intervention button for the specified polyp number.
475+
476+
Args:
477+
polyp_number (int): The number of the polyp.
478+
"""
479+
480+
self.click(
481+
self.page.locator(f"#spanPolypInterventionLink{polyp_number}").get_by_role(
482+
"link", name=self.add_intervention_string
483+
)
484+
)
485+
446486

447487
class SiteLookupOptions(StrEnum):
448488
"""Enum for site lookup options"""

pages/screening_subject_search/contact_with_patient_page.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from playwright.sync_api import Page
22
from pages.base_page import BasePage
3+
from utils.calendar_picker import CalendarPicker
4+
from datetime import datetime
35

46

57
class ContactWithPatientPage(BasePage):
@@ -84,3 +86,19 @@ def select_outcome_dropdown_option(self, outcome: str) -> None:
8486
def click_save_button(self) -> None:
8587
"""Click the 'Save' button to save the contact with patient form."""
8688
self.click(self.save_button)
89+
90+
def record_post_investigation_appointment_not_required(self) -> None:
91+
"""
92+
Record a post-investigation appointment not required contact.
93+
"""
94+
self.select_direction_dropdown_option("To patient")
95+
self.select_caller_id_dropdown_index_option(1)
96+
self.click_calendar_button()
97+
CalendarPicker(self.page).v1_calender_picker(datetime.today())
98+
self.enter_start_time("11:00")
99+
self.enter_end_time("12:00")
100+
self.enter_discussion_record_text("Test Automation")
101+
self.select_outcome_dropdown_option(
102+
"Post-investigation Appointment Not Required"
103+
)
104+
self.click_save_button()

0 commit comments

Comments
 (0)