Best Python code snippet using selene_python
test_settings_NC_RTL.py
Source:test_settings_NC_RTL.py
...12 # some subpages have their own subpages, and they need to be opened as well.13 #################### Wi-Fi and its subpages ######################14 wifi_page = settings.open_wifi()15 Wait(self.marionette).until(lambda m: wifi_page.is_wifi_enabled is True)16 self.take_screenshot('wifi-enabled')17 wifi_page.tap_connect_with_wps()18 self.take_screenshot('wifi-wps')19 settings.return_to_prev_menu(wifi_page.screen_element, wifi_page.wps_screen_element)20 self.marionette.execute_script('arguments[0].scrollIntoView(false);', [wifi_page.manage_network_button])21 wifi_page.tap_manage_networks()22 wifi_page.tap_join_hidden_network()23 wifi_page.tap_security_selector()24 self.take_screenshot('wifi-securityType', top_frame=True)25 wifi_page.tap_security_ok()26 self.take_screenshot('wifi-joinHidden')27 settings.return_to_prev_menu(wifi_page.manage_network_screen_element,28 wifi_page.join_hidden_network_screen_element)29 self.take_screenshot('wifi-manageNetwork')30 settings.return_to_prev_menu(wifi_page.screen_element, wifi_page.manage_network_screen_element)31 wifi_page.tap_manage_certs()32 wifi_page.tap_import_certs()33 self.take_screenshot('wifi-importCert')34 settings.return_to_prev_menu(wifi_page.manage_certs_screen_element, wifi_page.select_certs_screen_element)35 self.take_screenshot('wifi-manageCert')36 settings.return_to_prev_menu(wifi_page.screen_element, wifi_page.manage_certs_screen_element)37 wifi_page.disable_wifi()38 self.take_screenshot('wifi-disabled')39 settings.return_to_prev_menu(settings.screen_element, wifi_page.screen_element)40 #################### Sim manager and its subpages ######################41 sim_page = settings.open_sim_manager()42 self.take_screenshot('sim_manager')43 GaiaImageCompareTestCase.scroll(self.marionette, 'down',44 sim_page.screen_element.size['height'],45 screen = sim_page.screen_element)46 self.take_screenshot('sim_manager')47 sim_page.tap_sim_security()48 sim_page.enable_sim_pin()49 self.take_screenshot('sim_manager-pin_page')50 settings.return_to_prev_menu(sim_page.security_screen_element,51 sim_page.sim_pin_screen_element)52 self.take_screenshot('sim_manager-security')53 settings.return_to_prev_menu(sim_page.screen_element, sim_page.security_screen_element)54 settings.return_to_prev_menu(settings.screen_element, sim_page.screen_element)55 ################### Call Settings and its subpages ######################56 cs_page = settings.open_call()57 self.take_screenshot('cs-selectSIM')58 cs_page.tap_sim_1()59 self.take_screenshot('callsettings')60 cs_page.tap_voicemail()61 self.take_screenshot('voicemail')62 settings.return_to_prev_menu(cs_page.cs_screen_element, cs_page.vm_screen_element)63 cs_page.tap_caller_id_selection()64 self.take_screenshot('callerID', top_frame=True)65 cs_page.confirm_caller_id_selection()66 cs_page.tap_fixed_dialing()67 self.take_screenshot('fixeddialing')68 cs_page.tap_auth_numbers()69 self.take_screenshot('authNumbers')70 settings.return_to_prev_menu(cs_page.fixed_dialing_screen_element,71 cs_page.auth_screen_element)72 cs_page.enable_fixed_dialing()73 self.take_screenshot('enableFDN')74 settings.return_to_prev_menu(cs_page.fixed_dialing_screen_element,75 cs_page.fixed_dialing_simpin_screen_element)76 settings.return_to_prev_menu(cs_page.cs_screen_element,77 cs_page.fixed_dialing_screen_element)78 cs_page.tap_call_forwarding()79 self.take_screenshot('callforward_init')80 cs_page.wait_until_call_forwarding_info_received()81 self.take_screenshot('callforward')82 cs_page.tap_always_forward()83 self.take_screenshot('alwaysFwd')84 settings.return_to_prev_menu(cs_page.call_forwarding_screen_element,85 cs_page.call_forwarding_always_screen_element)86 cs_page.tap_forward_when_busy()87 self.take_screenshot('busyFwd')88 settings.return_to_prev_menu(cs_page.call_forwarding_screen_element,89 cs_page.call_forwarding_busy_screen_element)90 cs_page.tap_forward_unanswered()91 self.take_screenshot('unansweredFwd')92 settings.return_to_prev_menu(cs_page.call_forwarding_screen_element,93 cs_page.call_forwarding_unans_screen_element)94 cs_page.tap_forward_unreachable()95 self.take_screenshot('unreachFwd')96 settings.return_to_prev_menu(cs_page.call_forwarding_screen_element,97 cs_page.call_forwarding_unreach_screen_element)98 settings.return_to_prev_menu(cs_page.cs_screen_element, cs_page.call_forwarding_screen_element)99 cs_page.tap_call_barring()100 self.take_screenshot('callBarring-init')101 cs_page.wait_until_call_barring_info_received() # this sometimes happens in less than a second,102 # making it difficult to obtain init view103 self.take_screenshot('callBarring')104 GaiaImageCompareTestCase.scroll(self.marionette, 'down',105 cs_page.call_barring_screen_element.size['height'],106 screen = cs_page.call_barring_screen_element)107 self.take_screenshot('callBarring')108 cs_page.tap_change_passcode()109 self.take_screenshot('callBarring-passcode')110 settings.return_to_prev_menu(cs_page.call_barring_screen_element,111 cs_page.call_barring_passcode_screen_element)112 cs_page.tap_call_barring_all()113 self.take_screenshot('callBarring-passcode2')114 cs_page.tap_call_barring_all_cancel()115 settings.return_to_prev_menu(cs_page.cs_screen_element, cs_page.call_barring_screen_element)116 settings.return_to_prev_menu(cs_page.screen_element, cs_page.cs_screen_element)117 settings.return_to_prev_menu(settings.screen_element, cs_page.screen_element)118 ################## Messaging Settings and its subpages ######################119 messaging_page = settings.open_message()120 self.take_screenshot('message')121 GaiaImageCompareTestCase.scroll(self.marionette, 'down',122 messaging_page.screen_element.size['height'],123 screen = messaging_page.screen_element)124 self.take_screenshot('message')125 messaging_page.tap_auto_retrieve_selector()126 self.take_screenshot('message-autoretrieve_options',top_frame=True)127 messaging_page.close_retrieve_dialog()128 messaging_page.select_sim_1()129 self.take_screenshot('message-sim_1')130 settings.return_to_prev_menu(messaging_page.screen_element,131 messaging_page.settings_screen_element)132 settings.return_to_prev_menu(settings.screen_element, messaging_page.screen_element)133 ################### Cellular & Data and its subpages ######################134 cell_data_page = settings.open_cell_and_data()135 self.take_screenshot('cell_and_data')136 cell_data_page.enable_data()137 self.take_screenshot('data_enable_prompt')138 cell_data_page.data_prompt.turn_on()139 Wait(self.marionette).until(lambda m: cell_data_page.is_data_toggle_checked is True)140 cell_data_page.enable_roaming()141 self.take_screenshot('roaming_enable_prompt')142 cell_data_page.data_prompt.turn_on()143 Wait(self.marionette).until(lambda m: cell_data_page.is_roaming_toggle_checked is True)144 self.take_screenshot('cell_and_data_enabled')145 sim_settings_page = cell_data_page.tap_sim_1_setting()146 self.take_screenshot('sim_1_setting')147 sim_settings_page.tap_network_operator()148 self.take_screenshot('network_op')149 sim_settings_page.tap_network_type()150 self.take_screenshot('cell_network_type',top_frame=True)151 sim_settings_page.confirm_network_type()152 settings.return_to_prev_menu(sim_settings_page.screen_element,153 sim_settings_page.network_op_screen_element)154 sim_settings_page.tap_apn_settings()155 self.take_screenshot('apn_settings')156 sim_settings_page.tap_reset_to_default()157 self.take_screenshot('apn_setting_reset')158 sim_settings_page.tap_cancel_reset()159 sim_settings_page.tap_data_settings()160 self.take_screenshot('apn_list') # all other settings show the same dialog161 sim_settings_page.tap_add_new_apn()162 self.take_screenshot('apn_editor')163 for i in range(0, 2):164 GaiaImageCompareTestCase.scroll(self.marionette, 'down',165 sim_settings_page.apn_editor_screen_element.size['height'],166 screen = sim_settings_page.apn_editor_screen_element)167 self.take_screenshot('apn_editor')168 sim_settings_page.select_authentication()169 self.take_screenshot('apn_authentication', top_frame=True)170 sim_settings_page.confirm_apn_selection()171 sim_settings_page.select_protocol()172 self.take_screenshot('apn_protocol', top_frame=True)173 sim_settings_page.confirm_apn_selection()174 sim_settings_page.select_roaming_protocol()175 self.take_screenshot('apn_roaming', top_frame=True)176 sim_settings_page.confirm_apn_selection()177 settings.return_to_prev_menu(sim_settings_page.data_settings_screen_element,178 sim_settings_page.apn_editor_screen_element)179 settings.return_to_prev_menu(sim_settings_page.apn_settings_screen_element,180 sim_settings_page.data_settings_screen_element)181 settings.return_to_prev_menu(sim_settings_page.screen_element,182 sim_settings_page.apn_settings_screen_element)183 settings.return_to_prev_menu(cell_data_page.screen_element, sim_settings_page.screen_element)184 settings.return_to_prev_menu(settings.screen_element, cell_data_page.screen_element)185 ################# Bluetooth and its subpages ######################186 bluetooth_page = settings.open_bluetooth()187 self.take_screenshot('bluetooth-disabled')188 bluetooth_page.refresh_root_element() # frame is switched, need to refresh the root189 bluetooth_page.enable_bluetooth()190 self.take_screenshot('bluetooth-enabled')191 bluetooth_page.refresh_root_element()192 bluetooth_page.tap_rename_my_device()193 self.take_screenshot('bluetooth-renameDevice')194 bluetooth_page.refresh_root_element()195 bluetooth_page.tap_update_device_name_ok()196 bluetooth_page.disable_bluetooth()197 settings.return_to_prev_menu(settings.screen_element, bluetooth_page.screen_element)198 ##################### Internet sharing and its subpages ######################199 internet_settings_page = settings.open_internet_sharing()200 self.take_screenshot('internet_sharing')201 internet_settings_page.enable_hotspot()202 self.take_screenshot('internet_sharing-hotspot_enabled')203 hotspot_page = internet_settings_page.tap_hotspot_settings()204 self.take_screenshot('internet_sharing-hotspot')205 hotspot_page.tap_security_settings()206 self.take_screenshot('internet_sharing-hotspot-security',top_frame=True)207 hotspot_page.confirm_security_settings()208 settings.return_to_prev_menu(internet_settings_page.screen_element,209 hotspot_page.screen_element)210 settings.return_to_prev_menu(settings.screen_element,211 internet_settings_page.screen_element)212 def tearDown(self):213 self.marionette.switch_to_frame()214 self.data_layer.disable_cell_data()...
actions_lib.py
Source:actions_lib.py
...47sst.actions._make_results_dir()48params.SCREENSHOT_DIR = sst.config.results_directory495051def take_screenshot(name=None):52 global __TESTCASE_ID__53 54 if name==None:55 filename = '%s.png' % __TESTCASE_ID__56 else:57 filename = '%s.png' % (str(name)+'-'+datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))58 sst.actions.take_screenshot(filename)59 with open(os.path.join(params.SCREENSHOT_DIR,filename),'rb') as f:60 import base6461 #logger.info('<img src="data:image/png;base64,%s" width="1200px"/>' % (base64.b64encode(f.read())), True, False)62 63 64def dump_pagesource(name=None):65 global __TESTCASE_ID__66 67 sst.actions._print('Capturing page source')68 if name==None:69 filename = '%s.html' % __TESTCASE_ID__70 else:71 filename = '%s.html' % name72
...
test_pay_ui.py
Source:test_pay_ui.py
...51 def test_add_credit_card_completed(self):52 payment_types = self.main_view.get_payment_types()53 self.assertThat(payment_types.get_option_count(), Equals(3))54 self.main_view.open_add_card_page()55 self.take_screenshot('add_card_page')56 self.main_view.tap_on_webview()57 self.assertThat(payment_types.get_option_count, Eventually(Equals(4)))58 def test_add_credit_card_returns_on_cancel(self):59 self.mock_server.set_interaction_result_cancelled()60 payment_types = self.main_view.get_payment_types()61 self.assertThat(payment_types.get_option_count(), Equals(3))62 self.main_view.open_add_card_page()63 self.take_screenshot('add_card_page')64 self.main_view.tap_on_webview()65 checkout_page = self.main_view.get_checkout_page()66 self.assertThat(checkout_page.get_properties()["active"],67 Eventually(Equals(True)))68 def test_add_credit_card_cancelled(self):69 self.mock_server.set_interaction_result_cancelled()70 payment_types = self.main_view.get_payment_types()71 self.assertThat(payment_types.get_option_count(), Equals(3))72 self.main_view.open_add_card_page()73 self.take_screenshot('add_card_page')74 self.main_view.tap_on_webview()75 self.assertThat(payment_types.get_option_count, Eventually(Equals(3)))76 @testtools.skip('JS Alert dialog seems to not work.')77 def test_add_credit_card_js_alert(self):78 payment_types = self.main_view.get_payment_types()79 self.assertThat(payment_types.get_option_count(), Equals(3))80 self.main_view.open_add_card_page()81 self.take_screenshot('add_card_page')82 self.main_view.tap_dialog_ok_button()83 self.assertThat(payment_types.get_option_count, Eventually(Equals(4)))84 def test_add_credit_card_js_beforeunload(self):85 payment_types = self.main_view.get_payment_types()86 self.assertThat(payment_types.get_option_count(), Equals(3))87 self.main_view.open_add_card_page()88 self.take_screenshot('add_card_page')89 self.main_view.tap_dialog_stay_button()90 self.main_view.tap_on_webview()91 self.assertThat(payment_types.get_option_count, Eventually(Equals(4)))92 @testtools.skip('Clicking add card link second seems to not work.')93 def test_add_credit_card_js_beforeunload_twice(self):94 payment_types = self.main_view.get_payment_types()95 self.assertThat(payment_types.get_option_count(), Equals(3))96 self.main_view.open_add_card_page()97 self.take_screenshot('add_card_page')98 self.main_view.tap_dialog_leave_button()99 self.take_screenshot('beforeunload_left')100 self.main_view.open_add_card_page()101 self.take_screenshot('beforeunload_back')102 self.main_view.tap_dialog_stay_button()103 self.main_view.tap_on_web_view()104 self.assertThat(payment_types.get_option_count, Eventually(Equals(4)))105 def test_add_credit_card_js_beforeunload_cancelled(self):106 payment_types = self.main_view.get_payment_types()107 self.assertThat(payment_types.get_option_count(), Equals(3))108 self.main_view.open_add_card_page()109 self.take_screenshot('add_card_page')110 self.main_view.tap_dialog_leave_button()111 self.take_screenshot('beforeunload_cancelled')112 self.assertThat(payment_types.get_option_count, Eventually(Equals(3)))113 def test_add_credit_card_js_confirm_ok(self):114 payment_types = self.main_view.get_payment_types()115 self.assertThat(payment_types.get_option_count(), Equals(3))116 self.main_view.open_add_card_page()117 self.take_screenshot('add_card_page')118 self.main_view.tap_dialog_ok_button()119 self.assertThat(payment_types.get_option_count, Eventually(Equals(4)))120 def test_add_credit_card_js_confirm_cancel(self):121 payment_types = self.main_view.get_payment_types()122 self.assertThat(payment_types.get_option_count(), Equals(3))123 self.main_view.open_add_card_page()124 self.take_screenshot('add_card_page')125 self.main_view.tap_dialog_cancel_button()126 self.assertThat(payment_types.get_option_count, Eventually(Equals(3)))127 def test_add_credit_card_js_prompt_ok(self):128 payment_types = self.main_view.get_payment_types()129 self.assertThat(payment_types.get_option_count(), Equals(3))130 self.main_view.open_add_card_page()131 self.take_screenshot('add_card_page')132 self.main_view.input_dialog_text('friend')133 self.main_view.tap_dialog_ok_button()134 self.assertThat(payment_types.get_option_count, Eventually(Equals(4)))135 def test_add_credit_card_js_prompt_ok_wrong_text(self):136 payment_types = self.main_view.get_payment_types()137 self.assertThat(payment_types.get_option_count(), Equals(3))138 self.main_view.open_add_card_page()139 self.take_screenshot('add_card_page')140 self.main_view.input_dialog_text('amigo')141 self.main_view.tap_dialog_ok_button()142 self.assertThat(payment_types.get_option_count, Eventually(Equals(3)))143 def test_add_credit_card_js_prompt_cancel(self):144 payment_types = self.main_view.get_payment_types()145 self.assertThat(payment_types.get_option_count(), Equals(3))146 self.main_view.open_add_card_page()147 self.take_screenshot('add_card_page')148 self.main_view.tap_dialog_cancel_button()149 self.assertThat(payment_types.get_option_count, Eventually(Equals(3)))150 def test_purchase_with_web_interaction_completed(self):151 self.skipTest('Mouse clicks on buyButton not registering.')152 self.mock_server.set_purchase_needs_cc_interaction()153 self.main_view.buy()154 self.main_view.tap_on_webview()155 self.assertThat(self.app_returncode(), Equals(0))156 def test_purchase_with_web_interaction_cancelled(self):157 self.skipTest('Mouse clicks on buyButton not registering.')158 self.mock_server.set_purchase_needs_cc_interaction()159 self.mock_server.set_interaction_result_cancelled()160 self.main_view.buy()161 self.main_view.tap_on_webview()...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!