def bluetooth_scan(): controller = RemoteController("N0AA003759K70700223") bluetooth = controller.get_bluetooth_adapter() bluetooth.enable() wait(condition=lambda: bluetooth.is_enabled(), max_timeout=15, waiting_for='bluetooth enabled', error_msg='bluetooth disabled') bluetooth.start_discovery() wait(condition=lambda: bluetooth.is_discovering(), max_timeout=15, waiting_for='bluetooth discovering', error_msg='bluetooth not discovering') time.sleep(10) bluetooth.cancel_discovery() list_devices = bluetooth.get_discovered_devices() for device in list_devices: device.get_pair_state() device.get_name() device.get_type() device.get_bluetooth_class() print("---------------------------------")
def wifi_scan_results(): controller = RemoteController("N0AA003759K70700223") controller.start_view(Actions.ACTION_WIFI_SETTINGS) wifi = controller.get_wifi_adapter() wifi.enable() wait(condition=lambda: wifi.is_enabled(), max_timeout=15, waiting_for='wifi enabled', error_msg='wifi disabled') wifi.start_scan() time.sleep(6) for scan_result in wifi.get_scan_results(): print(scan_result) wifi.disable() wait(condition=lambda: not wifi.is_enabled(), max_timeout=15, waiting_for='wifi enabled', error_msg='wifi disabled')
def credit(): clear() print("made with love by Laodeus") print("extreme 2d graphisme by Laodeus") print("silent music by Laodeus") print("(i)logic by Laodeus") wait() clear()
def wait_page(self): time.sleep(1) def wait_ajax(dr): script = "if (typeof jQuery !== 'undefined') { return jQuery.active }" res = dr.execute_script(script) if res is None: time.sleep(7) return True elif res == 0: return True else: return False wait(lambda: wait_ajax(self._driver), timeout_seconds=utils.settings.get_wait())
def bluetooth_discoverable(): controller = RemoteController("N0AA003759K70700223") bluetooth = controller.get_bluetooth_adapter() bluetooth.enable() wait(condition=lambda: bluetooth.is_enabled(), max_timeout=15, waiting_for='bluetooth enabled', error_msg='bluetooth disabled') bluetooth.start_discoverable(120) wait(condition=lambda: bluetooth.is_discoverable(), max_timeout=15, waiting_for='bluetooth discoverable', error_msg='bluetooth not discoverable')
def bluetooth_enable_disable(): controller = RemoteController("N0AA003759K70700223") controller.start_view(Actions.ACTION_BLUETOOTH_SETTINGS) bluetooth = controller.get_bluetooth_adapter() bluetooth.enable() wait(condition=lambda: bluetooth.is_enabled(), max_timeout=15, waiting_for='bluetooth enabled', error_msg='bluetooth disabled') bluetooth.disable() wait(condition=lambda: not bluetooth.is_enabled(), max_timeout=15, waiting_for='bluetooth disabled', error_msg='bluetooth enabled')
def bluetooth_change_name(): controller = RemoteController("N0AA003759K70700223") controller.start_view(Actions.ACTION_BLUETOOTH_SETTINGS) bluetooth = controller.get_bluetooth_adapter() bluetooth.enable() wait(condition=lambda: bluetooth.is_enabled(), max_timeout=15, waiting_for='bluetooth enabled', error_msg='bluetooth disabled') previous_name = bluetooth.get_name() bluetooth.set_name("TestName") assert bluetooth.get_name() == "TestName" bluetooth.set_name(previous_name)
def wifi_connect_network(): controller = RemoteController("N0AA003759K70700223") controller.start_view(Actions.ACTION_WIFI_SETTINGS) wifi = controller.get_wifi_adapter() wifi.enable() wait(condition=lambda: wifi.is_enabled(), max_timeout=15, waiting_for='wifi enabled', error_msg='wifi disabled') net_id = wifi.add_network("RNS_AES", "12345678", SecurityType.PASS) wifi.enable_network(net_id=net_id) wait(condition=lambda: wifi.is_network_connected(), max_timeout=15, waiting_for='wifi enabled', error_msg='wifi disabled') for net in wifi.get_configured_networks(): print(net.SSID) wifi.remove_network(net_id=net_id) wifi.disable() wait(condition=lambda: not wifi.is_enabled(), max_timeout=15, waiting_for='wifi enabled', error_msg='wifi disabled')
def answer_incoming_call(): controller = RemoteController("N0AA003759K70700223") telecom = controller.get_telecom_adapter() # TODO call to your test phone ) wait(condition=lambda: telecom.get_call_state() == CallState.INCOMING_CALL, max_timeout=45, waiting_for='incoming call', error_msg='nobody calling)') telecom.answer_incoming_call() time.sleep(5) telecom.end_call() wait(condition=lambda: telecom.get_call_state() == CallState.NONE, max_timeout=15, waiting_for='not in call', error_msg='in call')
def bluetooth_pair(): controller = RemoteController("N0AA003759K70700223") controller2 = RemoteController("N0AA003759K70700223") bluetooth = controller.get_bluetooth_adapter() bluetooth2 = controller2.get_bluetooth_adapter() bluetooth.enable() bluetooth2.enable() wait(condition=lambda: bluetooth.is_enabled(), max_timeout=15, waiting_for='bluetooth enabled', error_msg='bluetooth disabled') wait(condition=lambda: bluetooth2.is_enabled(), max_timeout=15, waiting_for='bluetooth enabled', error_msg='bluetooth disabled') bluetooth.pair(bluetooth2.get_address()) time.sleep(5)
def call_state_test(): controller = RemoteController("N0AA003759K70700223") telecom = controller.get_telecom_adapter() telecom.get_call_state() telecom.call("466") wait(condition=lambda: telecom.get_call_state() == CallState.IN_CALL, max_timeout=15, waiting_for='in call', error_msg='not in call') time.sleep(5) telecom.get_call_state() telecom.end_call() wait(condition=lambda: telecom.get_call_state() == CallState.NONE, max_timeout=15, waiting_for='not in call', error_msg='in call')
def is_element_present(self, element_name, just_in_dom=False, timeout=20): def _get_driver(): driver = getattr(self, "_driver", None) if driver: return driver return get_driver() _get_driver().implicitly_wait(timeout) try: def is_displayed(): element = getattr(self, element_name, None) if not element: raise WebDriverException('No element "%s" within container %s' % (element_name, self)) return element.is_displayed() is_displayed() if just_in_dom else wait(lambda: is_displayed(), timeout_seconds=timeout) return True except WebDriverException: return False except TimeoutExpired: return False finally: _get_driver().implicitly_wait(utils.settings.get_implicit())
def print_hi(name): # Use a breakpoint in the code line below to debug your script. print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. # Press the green button in the gutter to run the script. if __name__ == '__main__': controller = RemoteController("N0AA003759K70700223") adapter = controller.get_wifi_adapter() adapter.enable() wait(condition=lambda: adapter.is_enabled(), max_timeout=15, waiting_for='wifi enabled', error_msg='wifi disabled') net_id = adapter.add_network("RNS_AES", "12345678", SecurityType.PASS) adapter.enable_network(net_id=net_id) time.sleep(15) adapter.remove_network(net_id=net_id) adapter.disable() wait(condition=lambda: not adapter.is_enabled(), max_timeout=15, waiting_for='wifi enabled',
def wait_title(driver, title): def wait_page_title(dr): return dr.title.__eq__(title) wait(lambda: wait_page_title(driver), timeout_seconds=utils.settings.get_wait())