|
| 1 | +from playwright.sync_api import Page |
| 2 | +import logging |
| 3 | +from datetime import datetime |
| 4 | +from pages.base_page import BasePage |
| 5 | + |
| 6 | + |
| 7 | +class ManualCeasePage(BasePage): |
| 8 | + """This class contains locators to interact with the manual cease page.""" |
| 9 | + |
| 10 | + def __init__(self, page: Page): |
| 11 | + self.page = page |
| 12 | + self.request_cease_button = page.locator("input[name='BTN_REQUEST_CEASE']") |
| 13 | + self.cease_reason_dropdown = page.locator("#A_C_RequestCeaseReason") |
| 14 | + self.notes_textbox = page.get_by_role("textbox", name="Notes (up to 500 char)") |
| 15 | + self.date_confirmed_field = page.get_by_label("Date Confirmed") |
| 16 | + self.confirm_cease_button = page.get_by_role("button", name="Confirm Cease") |
| 17 | + self.save_request_cease_button = page.locator( |
| 18 | + "input[name='BTN_SAVE'][value='Save Request Cease']" |
| 19 | + ) |
| 20 | + self.summary_table = page.locator("#screeningSummaryTable") |
| 21 | + self.record_disclaimer_sent_button = page.get_by_role( |
| 22 | + "button", name="Record Disclaimer Letter Sent" |
| 23 | + ) |
| 24 | + self.confirm_disclaimer_sent_button = page.get_by_role("button", name="Confirm") |
| 25 | + self.record_return_disclaimer_button = page.get_by_role( |
| 26 | + "button", name="Record Return of Disclaimer Letter" |
| 27 | + ) |
| 28 | + self.notes_field = page.get_by_label("Notes") |
| 29 | + |
| 30 | + def click_request_cease(self) -> None: |
| 31 | + """Clicks the 'Request Cease' button.""" |
| 32 | + self.click(self.request_cease_button) |
| 33 | + |
| 34 | + def select_cease_reason(self, reason: str) -> None: |
| 35 | + """Selects a given cease reason from the dropdown. |
| 36 | + Args: |
| 37 | + reason (str): The reason to select from the dropdown. |
| 38 | + """ |
| 39 | + self.cease_reason_dropdown.select_option(label=reason) |
| 40 | + |
| 41 | + def click_save_request_cease(self) -> None: |
| 42 | + """Clicks the 'Save Request Cease' button.""" |
| 43 | + self.click(self.save_request_cease_button) |
| 44 | + |
| 45 | + def record_disclaimer_sent(self) -> None: |
| 46 | + """Clicks the 'Record the disclaimer letter has been sent' button.""" |
| 47 | + self.click(self.record_disclaimer_sent_button) |
| 48 | + |
| 49 | + def confirm_disclaimer_sent(self) -> None: |
| 50 | + """Clicks the 'Confirm disclaimer letter has been sent' button.""" |
| 51 | + self.click(self.confirm_disclaimer_sent_button) |
| 52 | + |
| 53 | + def record_return_of_disclaimer(self) -> None: |
| 54 | + """Clicks the 'Record the return of the disclaimer letter' button.""" |
| 55 | + self.click(self.record_return_disclaimer_button) |
| 56 | + |
| 57 | + def fill_notes_and_date(self, notes: str = "AUTO TEST: notes") -> None: |
| 58 | + """Fills in notes and today's date in the form. |
| 59 | + Args: |
| 60 | + notes (str): Notes to fill in the text box. |
| 61 | + """ |
| 62 | + self.notes_field.fill(notes) |
| 63 | + today_str = datetime.today().strftime("%d/%m/%Y") |
| 64 | + self.date_confirmed_field.fill(today_str) |
| 65 | + |
| 66 | + def confirm_cease(self) -> None: |
| 67 | + """Clicks the 'Confirm cease' button and accepts dialog.""" |
| 68 | + self.safe_accept_dialog(self.confirm_cease_button) |
| 69 | + |
| 70 | + def fill_notes_if_visible(self, notes: str = "AUTO TEST: notes") -> None: |
| 71 | + """Fills in notes if the notes textbox is visible. |
| 72 | + Args: |
| 73 | + notes (str): Notes to fill in the text box. |
| 74 | + """ |
| 75 | + if self.notes_textbox.is_visible(): |
| 76 | + self.notes_textbox.fill(notes) |
| 77 | + |
| 78 | + def fill_date_if_visible(self, date_str: str) -> None: |
| 79 | + """Fills in today's date if the date confirmed field is visible. |
| 80 | + Args: |
| 81 | + date_str (str): Date to fill in the date confirmed field. |
| 82 | + """ |
| 83 | + if self.date_confirmed_field.is_visible(): |
| 84 | + self.date_confirmed_field.fill(date_str) |
| 85 | + |
| 86 | + def confirm_or_save_cease(self) -> None: |
| 87 | + """Confirms the cease action via either 'Confirm Cease' or 'Save Request Cease' button.""" |
| 88 | + if self.confirm_cease_button.is_visible(): |
| 89 | + BasePage(self.page).safe_accept_dialog(self.confirm_cease_button) |
| 90 | + |
| 91 | + elif self.save_request_cease_button.is_visible(): |
| 92 | + self.click(self.save_request_cease_button) |
| 93 | + else: |
| 94 | + logging.error("No cease confirmation button found!") |
| 95 | + raise RuntimeError("Cease button not found on the page") |
0 commit comments