Skip to content

Commit b7e6fc4

Browse files
Adding scenarios A-K from nohistology.feature
1 parent ce60049 commit b7e6fc4

File tree

9 files changed

+2021
-972
lines changed

9 files changed

+2021
-972
lines changed

pages/base_page.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def safe_accept_dialog(self, locator: Locator) -> None:
250250
except Exception as e:
251251
logging.error(f"Click failed: {e}")
252252

253-
def assert_dialog_text(self, expected_text: str) -> None:
253+
def assert_dialog_text(self, expected_text: str, accept: bool = False) -> None:
254254
"""
255255
Asserts that a dialog appears and contains the expected text.
256256
If no dialog appears, logs an error.
@@ -259,7 +259,7 @@ def assert_dialog_text(self, expected_text: str) -> None:
259259
"""
260260
self._dialog_assertion_error = None
261261

262-
def handle_dialog(dialog: Dialog):
262+
def handle_dialog(dialog: Dialog, accept: bool = False):
263263
logging.info(f"Dialog appeared with message: {dialog.message}")
264264
actual_text = dialog.message
265265
try:
@@ -268,9 +268,12 @@ def handle_dialog(dialog: Dialog):
268268
), f"Expected '{expected_text}', but got '{actual_text}'"
269269
except AssertionError as e:
270270
self._dialog_assertion_error = e
271-
dialog.dismiss() # Dismiss dialog
271+
if accept:
272+
dialog.accept()
273+
else:
274+
dialog.dismiss() # Dismiss dialog
272275

273-
self.page.once("dialog", handle_dialog)
276+
self.page.once("dialog", lambda dialog: handle_dialog(dialog, accept))
274277

275278
def go_to_log_in_page(self) -> None:
276279
"""Click on the Log in button to navigate to the login page."""

pages/datasets/investigation_dataset_page.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,29 @@ def click_polyp_add_intervention_button(self, polyp_number: int) -> None:
483483
)
484484
)
485485

486+
def populate_select_by_id(
487+
self, field_base: str, polyp_number: int, option: str
488+
) -> None:
489+
"""
490+
Populates a <select> element using a predictable ID pattern based on field name and polyp number.
491+
492+
This method is useful when label-based selectors (e.g., using `right-of(:text(...))`) are unreliable
493+
due to ambiguous or repeated text labels on the page.
494+
495+
Args:
496+
field_base (str): The base name of the field (e.g., "POLYP_PATHOLOGY_LOST").
497+
polyp_number (int): The polyp index (e.g., 1 for the first polyp).
498+
option (str): The value to be selected from the dropdown.
499+
500+
Example:
501+
populate_select_by_id("POLYP_PATHOLOGY_LOST", 1, YesNoOptions.YES)
502+
# Selects 'Yes' in <select id="UI_POLYP_PATHOLOGY_LOST1_1">
503+
"""
504+
field_id = f"UI_{field_base.upper()}{polyp_number}_1"
505+
locator = self.page.locator(f"select#{field_id}")
506+
locator.wait_for(state="visible")
507+
locator.select_option(option)
508+
486509

487510
class SiteLookupOptions(StrEnum):
488511
"""Enum for site lookup options"""
@@ -685,6 +708,12 @@ class PolypInterventionModalityOptions(StrEnum):
685708
POLYPECTOMY = "17189~Resection"
686709
EMR = "17193~Resection"
687710
ESD = "17520~Resection"
711+
BIOPSY = "17190~Suspicion of cancer"
712+
CHROMOSCOPY = "17198"
713+
HAEMOSTATIC_TECHNIQUE = "17194"
714+
SUBMUCOSAL_LIFT = "203005"
715+
TATTOOING = "17192"
716+
TISSUE_DESTRUCTION = "17191"
688717

689718

690719
class PolypInterventionDeviceOptions(StrEnum):
@@ -695,6 +724,9 @@ class PolypInterventionDeviceOptions(StrEnum):
695724
COLD_SNARE = "17072"
696725
COLD_BIOPSY = "17073~En-bloc"
697726
ENDOSCOPIC_KNIFE = "17531"
727+
HOT_BIOPSY_FORCEPS = "17071~En-bloc"
728+
ARGON_BEAM = "17077"
729+
LASER = "17078"
698730

699731

700732
class PolypInterventionExcisionTechniqueOptions(StrEnum):
@@ -768,3 +800,10 @@ class YesNoUncertainOptions(StrEnum):
768800
YES = "17058"
769801
NO = "17059"
770802
UNCERTAIN = "17105"
803+
804+
805+
class ReasonPathologyLostOptions(StrEnum):
806+
"""Enum for reason pathology lost options"""
807+
808+
LOST_IN_TRANSIT = "200561~~204337"
809+
DESTROYED_DURING_PROCESSING = "200562~~204337"

0 commit comments

Comments
 (0)