Skip to content

Commit e7b5ed2

Browse files
committed
Merge branch 'main' into feature/BCSS-20586-selenium-to-playwright-organisation
2 parents cb40bdc + f4441b5 commit e7b5ed2

18 files changed

+6116
-1030
lines changed

classes/diagnosis_date_reason_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ def get_valid_value_id(self) -> Optional[int]:
9898

9999
def get_description(self) -> str:
100100
"""
101-
Returns the description for the diagnosis date reason.
101+
Returns the description for the diagnosis date reason
102102
"""
103103
return self._description

pages/base_page.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,16 +250,23 @@ 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.
257257
Args:
258258
expected_text (str): The text that should be present in the dialog.
259+
accept (bool): Set to True if you want to accept the dialog, by deafult is is set to False.
259260
"""
260261
self._dialog_assertion_error = None
261262

262-
def handle_dialog(dialog: Dialog):
263+
def handle_dialog(dialog: Dialog, accept: bool = False):
264+
"""
265+
Handles the dialog and asserts that the dialog contains the expected text.
266+
Args:
267+
dialog (Dialog): the playwright dialog object
268+
accept (bool): Set to True if you want to accept the dialog, by deafult is is set to False.
269+
"""
263270
logging.info(f"Dialog appeared with message: {dialog.message}")
264271
actual_text = dialog.message
265272
try:
@@ -268,9 +275,12 @@ def handle_dialog(dialog: Dialog):
268275
), f"Expected '{expected_text}', but got '{actual_text}'"
269276
except AssertionError as e:
270277
self._dialog_assertion_error = e
271-
dialog.dismiss() # Dismiss dialog
278+
if accept:
279+
dialog.accept()
280+
else:
281+
dialog.dismiss() # Dismiss dialog
272282

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

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

0 commit comments

Comments
 (0)