|
| 1 | +import logging |
| 2 | +from playwright.sync_api import Page,expect |
| 3 | +from pages.base_page import BasePage |
| 4 | + |
| 5 | + |
| 6 | +class CreateOrganisation(BasePage): |
| 7 | + """Create Organisation Page locators, and methods for interacting with the page.""" |
| 8 | + |
| 9 | + def __init__(self, page: Page): |
| 10 | + super().__init__(page) |
| 11 | + self.page = page |
| 12 | + |
| 13 | + # Create Organisation links |
| 14 | + self.organisation_code = self.page.get_by_label("Organisation Code*") |
| 15 | + self.organisation_name = self.page.get_by_label("Organisation Name*") |
| 16 | + self.start_date_calendar = self.page.locator("#UI_START_DATE_LinkOrButton") |
| 17 | + self.audit_reason = self.page.get_by_label("Audit Reason*") |
| 18 | + self.date_of_diagnosis_textbox = self.page.get_by_role( |
| 19 | + "textbox", name="Date of Diagnosis" |
| 20 | + ) |
| 21 | + self.save_button = self.page.get_by_role("button", name="Save") |
| 22 | + |
| 23 | + def fill_organisation_code(self, text: str) -> None: |
| 24 | + """ |
| 25 | + This method is designed to fill in the Organisation Code field on the Create Organisation page. |
| 26 | + Returns: |
| 27 | + None |
| 28 | + """ |
| 29 | + logging.info("Filling Organisation Code on Create Organisation page") |
| 30 | + self.organisation_code.fill(text) |
| 31 | + |
| 32 | + def fill_organisation_name(self, text: str) -> None: |
| 33 | + """ |
| 34 | + This method is designed to fill in the Organisation Name field on the Create Organisation page. |
| 35 | + Returns: |
| 36 | + None |
| 37 | + """ |
| 38 | + logging.info("Filling Organisation Name on Create Organisation page") |
| 39 | + self.organisation_name.fill(text) |
| 40 | + |
| 41 | + def click_start_date_calendar(self) -> None: |
| 42 | + """ |
| 43 | + This method is designed to click the Start Date Calendar button on the Create Organisation page. |
| 44 | + Returns: |
| 45 | + None |
| 46 | + """ |
| 47 | + logging.info("Clicking Start Date Calendar on Create Organisation page") |
| 48 | + self.start_date_calendar.click() |
| 49 | + def fill_audit_reason(self, text: str) -> None: |
| 50 | + """ |
| 51 | + This method is designed to fill in the Audit Reason field on the Create Organisation page. |
| 52 | + Returns: |
| 53 | + None |
| 54 | + """ |
| 55 | + logging.info("Filling Audit Reason on Create Organisation page") |
| 56 | + self.audit_reason.fill(text) |
| 57 | + def click_save_button(self) -> None: |
| 58 | + """ |
| 59 | + This method is designed to click the Save button on the Create Organisation page. |
| 60 | + Returns: |
| 61 | + None |
| 62 | + """ |
| 63 | + logging.info("Clicking Save button on Create Organisation page") |
| 64 | + self.save_button.click() |
| 65 | + |
| 66 | + def verify_success_message(self) -> None: |
| 67 | + """ Verifies that the success message is displayed after saving the organisation. |
| 68 | + |
| 69 | + """ |
| 70 | + logging.info("Verifying success message on Create Organisation page") |
| 71 | + expect(self.page.locator("th")).to_contain_text("The action was performed successfully") |
0 commit comments