How to use switch_to_newest_tab method in SeleniumBase

Best Python code snippet using SeleniumBase

test_ui_and_basic_check.py

Source:test_ui_and_basic_check.py Github

copy

Full Screen

...38 ui = core_admin_ui39 ui.navigate("Settings", "Resources", "Password Storage", check_rendered_tab=False)40 ui.expect(Anchor("View Migration Job Status and Reports "), "Clicking migration job status").try_click(41 Span(text="Type"))42 ui.switch_to_newest_tab()43 ui._waitUntilSettled()44 ui.click_row(GridRowByGuid(result))45 ui.expect(Span("Details"), "Clicking migration job status").try_click(Div("Job Details"))46 ui.expect_value(Div(result), value=None, expected_value=result,47 wrong_value_message="expected id value is not matched in the report",48 text=True)49 logger.info("Id value in the Job description appeared correctly")50@pytest.mark.ui51@pytest.mark.pas52@pytest.mark.bhavna53def test_ui_check_job_details_page_values(core_session, core_admin_ui, list_of_created_systems):54 """55 Test case: C167056 :param core_session: Returns API session57 :param core_admin_ui: Centrify admin Ui session58 :param list_of_created_systems: returns the empty systems list.59 """60 account_name_prefix = f'account_test{guid()}'61 # adding multiple systems with accounts62 result = ResourceManager.add_multiple_systems_with_accounts(core_session, 1, 1, list_of_created_systems,63 user_prefix=account_name_prefix)64 # arranging the results in the lists65 all_systems, all_accounts = DataManipulation.aggregate_lists_in_dict_values([result])66 # Deleting systems for creating bulk delete scheduled report67 result_acc, success_acc = ResourceManager.del_multiple_accounts(core_session, all_accounts)68 assert success_acc, f"Api did not complete successfully for bulk account delete MSG:{result_acc}"69 # Deleting accounts for creating bulk delete scheduled report70 result_sys, success = ResourceManager.del_multiple_systems(core_session, all_systems)71 assert success, f'Delete systems job failed when expected success'72 logger.info(f"Delete systems job executed successfully {result_sys}")73 # Going to password storage page and click on migration job status link.74 ui = core_admin_ui75 ui.navigate("Settings", "Resources", "Password Storage", check_rendered_tab=False)76 ui.expect(Anchor("View Migration Job Status and Reports "), "Clicking migration job status").try_click()77 ui.switch_to_newest_tab()78 ui._waitUntilSettled()79 ui.click_row(GridRowByGuid(result_sys))80 ui.expect(Span("Details"), "Clicking migration job status").try_click(Div("Job Details"))81 # Checking the Job Id of system.82 ui.expect_value(Div(result_sys), value=None, expected_value=result_sys,83 wrong_value_message="expected id value is not matched in the report",84 text=True)85 logger.info("Id value in the Job description appeared correctly")86 # List of the Expected text from Job Details87 list_of_text = ['Job Information', 'Type', 'ID', 'Description', 'Submitted', 'Started', 'Completed',88 'Retry Count', 'Items Synced', 'Items Failed']89 # Getting the Job history90 job_history = JobManager.get_job_history(core_session)91 # Validating the Job history expected title appeared correctly on UI.92 for label in list_of_text:93 ui.expect_value(Label(label), value=None, expected_value=label,94 wrong_value_message=f"expected {label} value is not matched in the report",95 text=True)96 logger.info(f"expected {label} value is matched in the report")97 delete_scheduled_job = []98 check_text = []99 if job_history[1]['JobName'] == 'BulkSystemDelete':100 account_bulk_delete_schedule_id = job_history[0]['ID']101 System_bulk_delete_schedule_id = job_history[1]['ID']102 System_jobdescription = job_history[1]['JobDescription']103 System_jobName = job_history[1]['JobName']104 check_text.append(System_bulk_delete_schedule_id)105 check_text.append(System_jobdescription)106 check_text.append(System_jobName)107 check_text.append(account_bulk_delete_schedule_id)108 delete_scheduled_job.append(System_bulk_delete_schedule_id)109 ui.switch_context(RenderedTab("Job Details"))110 # Validating the Job history results from API appeared correctly on UI.111 for text in check_text:112 ui.expect_value(Div(text), value=None, expected_value=text,113 wrong_value_message=f"expected {text} value is not matched in the report",114 text=True)115 logger.info(f"expected {text} value is matched in the report")116 # Deleting the Scheduled jobs of Bulk System's and Account's117 for delete in delete_scheduled_job:118 result_account_delete, success, response = Discovery.delete_job_history(core_session, delete)119 assert success, f"Failed to delete Job history profile {result_account_delete}"120 logger.info(f"delete Job history profile with id {delete} successful {success}")121@pytest.mark.ui122@pytest.mark.pas123@pytest.mark.bhavna124def test_system_password_rotation(core_session, pas_setup, core_admin_ui):125 """126 Test Case ID: C1671127 :param core_session: Returns API session128 :param pas_setup: Creates System and Account129 :param core_admin_ui: Authenticates Centrify UI session130 """131 # Creating windows system.132 system_id, account_id, sys_info = pas_setup133 system_name = sys_info[0]134 # Navigating to System and enabling the "All Password Rotation" option with valid and invalid values.135 ui = core_admin_ui136 ui.navigate('Resources', 'Systems')137 ui.search(system_name)138 ui.click_row(GridRowByGuid(system_id))139 ui.tab('Advanced')140 ui.switch_context(RenderedTab("Advanced"))141 ui.select_option("AllowPasswordRotation", "Yes")142 expected_password_rotation_duration = 1143 ui.input("PasswordRotateDuration", expected_password_rotation_duration)144 ui.expect(Button("Save"), "Save button should enabled")145 logger.info("Save button enabled")146 ui.save()147 logger.info("Valid value 1 is accepted and saved successfully")148 # Checking the value is saved and reflected with the system's settings.149 system_list = RedrockController.get_computers(core_session)150 discovered_system = []151 for system in system_list:152 if system['Name'] == sys_info[0]:153 discovered_system.append(system['ID'])154 discovered_system.append(system['PasswordRotateDuration'])155 actual_password_rotation_duration = discovered_system[1]156 assert expected_password_rotation_duration == actual_password_rotation_duration, f"password rotation duration count {expected_password_rotation_duration} not matched with actual count {actual_password_rotation_duration}"157 logger.info(158 f"Password rotation duration of the system {system_name} with id {system_id} saved with count {actual_password_rotation_duration} ")159 # Changing the value of password rotation duration with invalid value 0.160 ui.tab('Advanced')161 ui.switch_context(RenderedTab("Advanced"))162 ui.select_option("AllowPasswordRotation", "Yes")163 ui.input("PasswordRotateDuration", 0)164 ui.save()165 ui.switch_context(ErrorModal())166 ui.expect(Div("Please correct the errors in your form before submitting."), " Error pop up should appear")167 logger.info("Invalid value 0 is not accepted and thrown error popup successfully")168@pytest.mark.ui169@pytest.mark.pas170@pytest.mark.bhavna171def test_password_storage_page(core_admin_ui):172 """173 Test Case ID: C1669174 :param core_admin_ui: Authenticates Centrify UI session175 """176 # Navigating to the Password Storage page and checking the UI.177 ui = core_admin_ui178 ui.navigate("Settings", "Resources", "Password Storage", check_rendered_tab=False)179 ui.expect(Label("Select the location where system passwords should be stored"),180 "Expected the 'Select the location' label to be appeared")181 logger.info("'Select the location where system passwords should be stored' appeared successfully")182 # Checking the 'Centrify Privileged Access Service' label183 ui.expect(Label("Centrify Privileged Access Service"),184 "Expected the 'Centrify Privileged Access Service' label to be appeared")185 logger.info("'Centrify Privileged Access Service' appeared successfully")186 # Checking the 'SafeNet KeySecure appliance' label187 ui.expect(Label("SafeNet KeySecure appliance"), "Expected the 'SafeNet KeySecure appliance' label to be appeared")188 logger.info("'SafeNet KeySecure appliance' appeared successfully")189 # Checking the 'Migrate Passwords' button190 ui.expect(Span("Migrate Passwords"), "Expected 'Migrate Passwords' button to be appeared")191 logger.info("'Migrate Passwords' button appeared successfully")192@pytest.mark.pas193@pytest.mark.ui194@pytest.mark.bhavna195def test_check_safenet(core_admin_ui):196 """197 Test Case ID: C1729198 :param core_admin_ui: Authenticates Centrify UI session199 """200 # Navigating to the Password Storage page and checking the tooptip and help pages.201 ui = core_admin_ui202 ui.navigate("Settings", "Resources", "Password Storage", check_rendered_tab=False)203 # Clicking the help tooltip at the begin of the page.204 ui.expect(Span(text="?"),205 'tooltip ? to be enabled').try_click(Span(text="Migrate Passwords"))206 ui.switch_to_newest_tab()207 ui.expect(PageWithTitle("Configuring password storage"),208 "Expecting a new page with title 'Configuring password storage'")209 logger.info("Title with the page 'Configuring password storage' loaded successfully'")210 ui.switch_to_main_window()211 ui.switch_context(ActiveMainContentArea())212 # Clicking the Learn more link in the password storage page.213 ui.expect(Anchor(button_text="Learn more"), "expecting a link named 'Learn more'").try_click(214 Span(text="Migrate Passwords"))215 ui.switch_to_newest_tab()216 ui.expect(PageWithTitle("Configuring password storage"),217 "Expecting a new page with title 'Configuring password storage'")218 logger.info("Title with the page 'Configuring password storage' loaded successfully'")219 ui.switch_to_main_window()220 ui.navigate("Settings", "Resources", ("SafeNet KeySecure Configuration", "SafeNet KeySecure Configuration"))221 # Clicking the Learn more link in the SafeNet KeySecure Configuration page.222 ui.expect(Anchor(button_text="Learn more"), "expecting a link named 'Learn more'").try_click(223 Div(text="SafeNet KeySecure Configuration"))224 ui.switch_to_newest_tab()225 ui.expect(PageWithTitle("Configuring communication with SafeNet KeySecure"),226 "Expecting a new page with title 'Configuring communication with SafeNet KeySecure'")227 logger.info("Title with the page 'Configuring communication with SafeNet KeySecure' loaded successfully'")228@pytest.mark.ui229@pytest.mark.pas230@pytest.mark.bhavna231def test_system_password_rotation_switch_page(core_session, pas_setup, core_admin_ui):232 """233 Test Case ID: C1672234 :param core_session: Returns API session235 :param pas_setup: Creates System and Account236 :param core_admin_ui: Authenticates Centrify UI session237 """238 # Creating windows system....

Full Screen

Full Screen

test_learn_more_help_check_for_secrets.py

Source:test_learn_more_help_check_for_secrets.py Github

copy

Full Screen

...33 ui.tab('Settings')34 link_selector = Anchor(button_text='Learn more')35 link_clicked = ui.expect(link_selector, expectation_message="Learn more Link to click")36 link_clicked.try_click()37 ui.switch_to_newest_tab()38 settings_pop_up = ui.check_exists(Header('Viewing and changing settings'))39 assert settings_pop_up, f'Failed to verify the {settings_pop_up}'40 logger.info(f'Settings pop up loading Successful:{settings_pop_up}')41 ui.close_browser()42 ui.switch_to_main_window()43 ui.tab('Policy')44 link_selector = Anchor(button_text='Learn more')45 link_clicked = ui.expect(link_selector, expectation_message="Learn more Link to click")46 link_clicked.try_click()47 ui.switch_to_newest_tab()48 policy_pop_up = ui.check_exists(Header('Setting access challenge policies'))49 assert policy_pop_up, f'Failed to verify the {policy_pop_up}'50 logger.info(f'Policy pop up loading Successful:{policy_pop_up}')51 ui.close_browser()52 ui.switch_to_main_window()53 ui.tab('Activity')54 link_selector = Anchor(button_text='Learn more')55 link_clicked = ui.expect(link_selector, expectation_message="Learn more Link to click")56 link_clicked.try_click()57 ui.switch_to_newest_tab()58 activity_pop_up = ui.check_exists(Header('Viewing activity for a secret or folder'))59 assert activity_pop_up, f'Failed to verify the {activity_pop_up}'60 logger.info(f'Activity pop up loading Successful:{activity_pop_up}')61 ui.close_browser()...

Full Screen

Full Screen

test_check_help_page_correctly.py

Source:test_check_help_page_correctly.py Github

copy

Full Screen

...14 ui.navigate("Settings", "Resources", "Password Profiles")15 # Clicking the 'Learn More' link in the Password profiles page.16 ui.expect(Anchor(button_text="Learn more"), "expecting a like named 'Learn more'", time_to_wait=20).try_click()17 logger.info("Clicked the Learn More link in the password profiles page")18 ui.switch_to_newest_tab()19 ui.expect(PageWithTitle("Configuring password profiles"), "Page with title 'Configuring password profiles'")20 logger.info("Verifying the page title appeared")21 ui.switch_to_main_window()22 # Clicking the 'Learn More' link in the Security Settings page.23 ui.navigate("Settings", "Resources", "Security", "Security Settings")24 ui.expect(Anchor(button_text="Learn more"), "expecting a link named 'Learn more'", time_to_wait=20).try_click(25 Label("SSH Gateway Banner"))26 logger.info("Clicked the Learn More link in the Security Settings page")27 ui.switch_to_newest_tab()28 ui.expect(PageWithTitle("Setting global security options"), "Page with title 'Setting global security options'")29 logger.info("Verifying the page title appeared")30 # Checking the password profile help page.31 ui.expect(Anchor(href="Password-profiles.htm"), "Expecting password profile page", time_to_wait=20).try_click(32 Header("Setting global security options"))33 logger.info("Clicking the password profile help page")34 ui.switch_to_newest_tab()35 ui.expect(PageWithTitle("Password profiles"), "Page with title 'Password profiles'")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful