Skip to content

Commit a682caa

Browse files
As per PR comments, Code is Refactored & all changes are Updated.
1 parent bf4ac09 commit a682caa

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed
Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
from playwright.sync_api import Page
2+
from pages.base_page import BasePage
23
from datetime import datetime
34

4-
class HandoverIntoSymptomaticCarePage:
5+
class HandoverIntoSymptomaticCarePage(BasePage):
6+
"""
7+
HandoverIntoSymptomaticCarePage class for interacting with the 'Handover Into Symptomatic Care' page elements.
8+
"""
59
def __init__(self, page: Page):
610
self.page = page
711
self.referral_dropdown = self.page.get_by_label("Referral")
812
self.calendar_button = self.page.get_by_role("button", name="Calendar")
913
self.consultant_link = self.page.locator("#UI_NS_CONSULTANT_PIO_SELECT_LINK")
10-
self.consultant_option = lambda value: self.page.locator(f'[value="{value}"]:visible')
1114
self.notes_textbox = self.page.get_by_role("textbox", name="Notes")
1215
self.save_button = self.page.get_by_role("button", name="Save")
1316

14-
def select_referral_dropdown_option(self, value: str):
17+
def select_referral_dropdown_option(self, value: str) -> None:
18+
"""Select a given option from the Referral dropdown."""
1519
self.referral_dropdown.select_option(value)
1620

1721
def click_calendar_button(self) -> None:
22+
"""Click the calendar button to open the calendar picker."""
1823
self.click(self.calendar_button)
1924

20-
def select_consultant(self, value: str):
25+
def select_consultant(self, value: str) -> None:
26+
"""Select a consultant from the dropdown."""
2127
self.consultant_link.click()
22-
option = self.consultant_option(value)
23-
option.wait_for(state="visible")
24-
option.click()
28+
option_locator = self.page.locator(f'[value="{value}"]:visible')
29+
option_locator.wait_for(state="visible")
30+
self.click(option_locator)
2531

26-
def fill_notes(self, notes: str):
32+
def fill_notes(self, notes: str) -> None:
33+
"""Fill the notes textbox with the given text."""
2734
self.notes_textbox.click()
2835
self.notes_textbox.fill(notes)
2936

30-
def click_save_button(self):
31-
self.page.once("dialog", lambda dialog: dialog.accept())
32-
self.click(self.save_button)
33-
37+
def click_save_button(self) -> None:
38+
"""Click the save button to save the changes."""
39+
self.safe_accept_dialog(self.save_button)

0 commit comments

Comments
 (0)