Skip to content

Commit daa5dc2

Browse files
As per PR # 98 comments, Code change is implemented.
1 parent 74de8f9 commit daa5dc2

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

pages/organisations/organisations_page.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from playwright.sync_api import Page
22
from pages.base_page import BasePage
3-
3+
from typing import List
44

55
class OrganisationsPage(BasePage):
66
"""Organisations Page locators, and methods for interacting with the page."""
@@ -51,36 +51,47 @@ def go_to_bureau_page(self) -> None:
5151
"""Clicks the 'Bureau' link."""
5252
self.click(self.bureau_page)
5353

54+
class OrganisationNotSelectedError(Exception):
55+
"""Raised when no organisation is selected on the organisation switch page."""
56+
pass
5457

5558
class OrganisationSwitchPage:
56-
"""Organisation Switch Page locators and methods for interacting with the page"""
59+
"""Organisation Switch Page locators and reusable interactions"""
60+
61+
SELECT_ORG_LINK_TEXT = "Select Org"
5762

5863
def __init__(self, page: Page):
5964
self.page = page
60-
self.radio_selector = "input[name='organisation']"
61-
self.select_org_link = "a:has-text('Select Organisation')"
6265

63-
RADIO_SELECTOR = "input[type='radio']"
64-
SELECT_ORG_LINK_TEXT = "Select Org"
65-
LOGIN_INFO_SELECTOR = "td.loginInfo"
66+
# Locators initialized using Playwright's locator API
67+
self.radio_buttons = self.page.locator("input[type='radio']")
68+
self.selected_radio = self.page.locator("input[name='organisation']:checked")
69+
self.continue_button = self.page.get_by_role("button", name="Continue")
70+
self.select_org_link = self.page.get_by_role("link", name=self.SELECT_ORG_LINK_TEXT)
71+
self.login_info = self.page.locator("td.loginInfo")
6672

67-
def get_available_organisation_ids(self) -> list[str]:
68-
radios = self.page.locator(self.RADIO_SELECTOR)
73+
def click(self, locator) -> None:
74+
locator.click()
75+
76+
def get_available_organisation_ids(self) -> List[str]:
6977
org_ids = []
70-
for int in range(radios.count()):
71-
org_id = radios.nth(int).get_attribute("id")
78+
count = self.radio_buttons.count()
79+
for element in range(count):
80+
org_id = self.radio_buttons.nth(element).get_attribute("id")
7281
if org_id:
7382
org_ids.append(org_id)
7483
return org_ids
7584

7685
def select_organisation_by_id(self, org_id: str) -> None:
77-
self.page.locator(f"#{org_id}").check()
86+
self.click(self.page.locator(f"#{org_id}"))
7887

7988
def click_continue(self) -> None:
80-
self.page.get_by_role("button", name="Continue").click()
89+
self.click(self.continue_button)
8190

8291
def click_select_org_link(self) -> None:
83-
self.page.get_by_role("link", name=self.SELECT_ORG_LINK_TEXT).click()
92+
self.click(self.select_org_link)
8493

8594
def get_logged_in_text(self) -> str:
86-
return self.page.locator(self.LOGIN_INFO_SELECTOR).inner_text()
95+
return self.login_info.inner_text()
96+
97+

0 commit comments

Comments
 (0)