33from playwright .sync_api import expect
44
55from pages .select_your_role import SelectYourRole
6+ from features .environment import MOCK_CIS2_LOGIN_ID
67
78
8- @when ("I go to the select_your_role page" )
9+ @when ("I go to the select your role page" )
910def i_go_to_the_select_your_role_page (context ):
1011 context .page .goto (context .cpts_ui_base_url + "site/selectyourrole.html" )
1112
1213
13- @given ("I am on the select_your_role page" )
14+ @given ("I am on the select your role page" )
1415def i_am_on_select_your_role_page (context ):
1516 i_go_to_the_select_your_role_page (context )
1617 select_your_role_page = SelectYourRole (context .page )
1718 expect (select_your_role_page .summary ).to_be_visible ()
1819
1920
20- @then ("I am on the select_your_role page" )
21+ @then ("I am on the select your role page" )
2122def verify_on_select_your_role_page (context ):
2223 select_your_role_page = SelectYourRole (context .page )
2324 expect (select_your_role_page .summary ).to_be_visible ()
@@ -27,7 +28,7 @@ def verify_on_select_your_role_page(context):
2728def login (context ):
2829 context .page .goto (context .cpts_ui_base_url + "site/auth_demo.html" )
2930 context .page .get_by_role ("button" , name = "Log in with mock CIS2" ).click ()
30- context .page .get_by_label ("Username" ).fill ("555073103100" )
31+ context .page .get_by_label ("Username" ).fill (MOCK_CIS2_LOGIN_ID )
3132 context .page .get_by_role ("button" , name = "Sign In" ).click ()
3233 context .page .wait_for_url ("**/auth_demo.html" )
3334
@@ -75,61 +76,24 @@ def click_on_summary_expander(context):
7576@then ("I can see the roles with access cards" )
7677def i_can_see_the_roles_with_access_cards (context ):
7778 select_your_role_page = SelectYourRole (context .page )
78- try :
79- expect (select_your_role_page .first_role_card ).to_be_visible (timeout = 5000 )
80- print ("Verified that at least one role card is displayed." )
81- except Exception as e :
82- print ("Error verifying roles with access cards:" , str (e ))
83- print ("Page content during error:" )
84- print (context .page .content ())
85- raise
79+ expect (select_your_role_page .first_role_card ).to_be_visible ()
8680
8781
88- @then ("I can navigate to the your_selected_role page by clicking a card" )
82+ @then ("I can navigate to the your selected role page by clicking a card" )
8983def i_can_navigate_to_the_your_selected_role_page (context ):
9084 select_your_role_page = SelectYourRole (context .page )
91- try :
92- expect (select_your_role_page .first_role_card ).to_be_visible (timeout = 5000 )
93- select_your_role_page .first_role_card .click ()
94- context .page .wait_for_url (select_your_role_page .selected_role_url )
95- print (
96- "Navigation to your_selected_role page successful. Current URL:" ,
97- context .page .url ,
98- )
99- except Exception as e :
100- print ("Error navigating to your_selected_role page:" , str (e ))
101- print ("Page content during error:" )
102- print (context .page .content ())
103- raise
104-
105-
106- @then ("I can see the your_selected_role header" )
85+ expect (select_your_role_page .first_role_card ).to_be_visible ()
86+ select_your_role_page .first_role_card .click ()
87+ context .page .wait_for_url (select_your_role_page .selected_role_url )
88+
89+
90+ @then ("I can see the your selected role header" )
10791def i_can_see_select_your_role_header (context ):
10892 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" )
93+ expect (select_your_role_page .select_role_header ).to_be_visible ()
94+
95+
96+ @then ("I can see the your selected role subheader" )
12397def i_can_see_select_your_role_subheader (context ):
12498 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
99+ expect (select_your_role_page .select_role_subheader ).to_be_visible ()
0 commit comments