Skip to content

Commit 2e8497a

Browse files
committed
Add tests for the Select Your Role header
1 parent cacc87d commit 2e8497a

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

features/cpts_ui/select_your_role.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,11 @@ Feature: Role selection page renders roles properly when logged in
3232
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4651
3333
Scenario: User can navigate to the your_selected_role page
3434
Then I can navigate to the your_selected_role page by clicking a card
35+
36+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4658
37+
Scenario: User can see the header on the select_your_role page
38+
Then I can see the your_selected_role header
39+
40+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4658
41+
Scenario: User can see the subheader on the select_your_role page
42+
Then I can see the your_selected_role subheader

features/steps/cpts_ui/select_your_role_steps.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,35 @@ def i_can_navigate_to_the_your_selected_role_page(context):
101101
print("Page content during error:")
102102
print(context.page.content())
103103
raise
104+
105+
106+
@then("I can see the your_selected_role header")
107+
def i_can_see_select_your_role_header(context):
108+
select_your_role_page = SelectYourRole(context.page)
109+
try:
110+
# Validate only the title text
111+
expect(select_your_role_page.select_role_header).to_have_text(
112+
select_your_role_page.select_role_header_text, timeout=5000
113+
)
114+
print("Verified the your_selected_role header text is correct.")
115+
except Exception as e:
116+
print("Error verifying the your_selected_role header text:", str(e))
117+
print("Page content during error:")
118+
print(context.page.content())
119+
raise
120+
121+
122+
@then("I can see the your_selected_role subheader")
123+
def i_can_see_select_your_role_subheader(context):
124+
select_your_role_page = SelectYourRole(context.page)
125+
try:
126+
# Validate the subheader text
127+
expect(select_your_role_page.select_role_subheader).to_have_text(
128+
f"- {select_your_role_page.select_role_subheader_text}", timeout=5000
129+
)
130+
print("Verified the your_selected_role subheader text is correct.")
131+
except Exception as e:
132+
print("Error verifying the your_selected_role subheader text:", str(e))
133+
print("Page content during error:")
134+
print(context.page.content())
135+
raise

pages/select_your_role.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33

44
class SelectYourRole:
55
def __init__(self, page: Page):
6+
"""
7+
Initialise the SelectYourRole page object with locators and text constants.
8+
"""
69
self.page = page
710

8-
self.slr_title = "Select your role"
11+
# Title and summary locators
912
self.summary = page.locator("summary")
1013
self.organisation_column_header = page.get_by_role(
1114
"columnheader", name="Organisation"
@@ -19,11 +22,27 @@ def __init__(self, page: Page):
1922
"cell", name="Registration Authority Agent"
2023
).first
2124

25+
# Role cards - roles with access
2226
self.roles_with_access_cards = page.locator(".nhsuk-card--clickable")
2327
self.first_role_card = self.roles_with_access_cards.first
2428
self.role_card_headings = page.locator(".nhsuk-card__heading")
2529
self.role_card_descriptions = page.locator(".eps-card__roleName")
2630
self.selected_role_url = "**/site/yourselectedrole"
2731

32+
# Header locators
33+
self.select_role_header = page.locator(
34+
"span[data-testid='eps_header_selectYourRole'] > span.nhsuk-title"
35+
)
36+
self.select_role_header_text = "Select your role"
37+
38+
# Subheader locators
39+
self.select_role_subheader = page.locator(
40+
"span.nhsuk-caption-l.nhsuk-caption--bottom"
41+
)
42+
self.select_role_subheader_text = (
43+
"Select the role you wish to use to access the service."
44+
)
45+
46+
# Header and footer locators
2847
self.header = "[id='eps_header']"
2948
self.footer = "[id='eps_footer']"

0 commit comments

Comments
 (0)