def test_toggle_wifi(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/toggle_wifi'), ) assert isinstance(driver.toggle_wifi(), WebDriver)
def test_hide_keyboard(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/hide_keyboard') ) assert isinstance(driver.hide_keyboard(), WebDriver)
def test_start_activity_with_opts(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/start_activity'), body='{"value": ""}' ) driver.start_activity( app_package='com.example.myapp', app_activity='.ExampleActivity', app_wait_package='com.example.waitapp', intent_action='android.intent.action.MAIN', intent_category='android.intent.category.LAUNCHER', intent_flags='0x10200000', optional_intent_arguments='--es "activity" ".ExampleActivity"', dont_stop_app_on_reset=True ) d = get_httpretty_request_body(httpretty.last_request()) assert d['appPackage'] == 'com.example.myapp' assert d['appActivity'] == '.ExampleActivity' assert d['appWaitPackage'] == 'com.example.waitapp' assert d['intentAction'] == 'android.intent.action.MAIN' assert d['intentCategory'] == 'android.intent.category.LAUNCHER' assert d['intentFlags'] == '0x10200000' assert d['optionalIntentArguments'] == '--es "activity" ".ExampleActivity"' assert d['dontStopAppOnReset'] is True
def test_islocked_false(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/is_locked'), body='{"value": false}' ) assert driver.is_locked() is False
def test_get_contexts(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.GET, appium_command('/session/1234567890/context'), body='{"value": "NATIVE"}' ) assert driver.current_context == 'NATIVE'
def test_get_settings_string(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.GET, appium_command('/session/1234567890/appium/settings'), body='{"value": {"sample": "string"}}' ) assert driver.get_settings()['sample'] == 'string'
def test_wait_activity(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.GET, appium_command('/session/1234567890/appium/device/current_activity'), body='{"value": ".ExampleActivity"}' ) assert driver.wait_activity('.ExampleActivity', 1) is True
def test_get_device_time(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.GET, appium_command('/session/1234567890/appium/device/system_time'), body='{"value": "2019-01-05T14:46:44+09:00"}' ) assert driver.get_device_time() == '2019-01-05T14:46:44+09:00'
def test_network_connection(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.GET, appium_command('/session/1234567890/network_connection'), body='{"value": 2}' ) assert driver.network_connection == 2
def test_clipboard_with_subsubclass(self): driver = self.android_w3c_driver(SubSubWebDriver) httpretty.register_uri( httpretty.GET, appium_command('/session/1234567890/context'), body='{"value": "NATIVE"}' ) assert driver.current_context == 'NATIVE'
def test_set_gsm_voice(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/gsm_voice'), ) assert isinstance(driver.set_gsm_voice(GsmVoiceState.ROAMING), WebDriver) d = get_httpretty_request_body(httpretty.last_request()) assert d['state'] == GsmVoiceState.ROAMING
def test_update_settings_string(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/settings'), ) assert isinstance(driver.update_settings({"sample": 'string'}), WebDriver) d = get_httpretty_request_body(httpretty.last_request()) assert d['settings']['sample'] == 'string'
def test_set_network_speed(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/network_speed'), ) assert isinstance(driver.set_network_speed(NetSpeed.LTE), WebDriver) d = get_httpretty_request_body(httpretty.last_request()) assert d['netspeed'] == NetSpeed.LTE
def test_set_power_ac(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/power_ac'), ) assert isinstance(driver.set_power_ac(Power.AC_ON), WebDriver) d = get_httpretty_request_body(httpretty.last_request()) assert d['state'] == Power.AC_ON
def test_set_power_capacity(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/power_capacity'), ) assert isinstance(driver.set_power_capacity(50), WebDriver) d = get_httpretty_request_body(httpretty.last_request()) assert d['percent'] == 50
def test_get_formatted_device_time(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/system_time'), body='{"value": "2019-01-08"}' ) assert driver.get_device_time('YYYY-MM-DD') == '2019-01-08' d = get_httpretty_request_body(httpretty.last_request()) assert d['format'] == 'YYYY-MM-DD'
def test_make_gsm_call(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/gsm_call'), ) assert isinstance(driver.make_gsm_call('5551234567', GsmCallActions.CALL), WebDriver) d = get_httpretty_request_body(httpretty.last_request()) assert d['phoneNumber'] == '5551234567' assert d['action'] == GsmCallActions.CALL
def test_set_network_connection(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/network_connection'), body='{"value": ""}' ) driver.set_network_connection(2) d = get_httpretty_request_body(httpretty.last_request()) assert d['parameters']['type'] == 2
def test_location(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.GET, appium_command('/session/1234567890/location'), body='{"value": {"latitude": 11.1, "longitude": 22.2, "altitude": 33.3}}' ) val = driver.location assert abs(val['latitude'] - 11.1) <= FLT_EPSILON assert abs(val['longitude'] - 22.2) <= FLT_EPSILON assert abs(val['altitude'] - 33.3) <= FLT_EPSILON
def test_lock(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/lock'), body='{"value": ""}' ) driver.lock(1) d = get_httpretty_request_body(httpretty.last_request()) assert d['seconds'] == 1
def test_set_gsm_signal(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/gsm_signal'), ) assert isinstance(driver.set_gsm_signal(GsmSignalStrength.GREAT), WebDriver) d = get_httpretty_request_body(httpretty.last_request()) assert d['signalStrength'] == GsmSignalStrength.GREAT assert d['signalStrengh'] == GsmSignalStrength.GREAT
def test_reset(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/app/reset'), body='{"value": ""}' ) result = driver.reset() assert {'sessionId': '1234567890'}, get_httpretty_request_body(httpretty.last_request()) assert isinstance(result, WebDriver)
def test_finger_print(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/finger_print'), # body is None ) assert driver.finger_print(1) is None d = get_httpretty_request_body(httpretty.last_request()) assert d['fingerprintId'] == 1
def test_set_clipboard_text(self): driver = ios_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/set_clipboard'), body='{"value": ""}' ) driver.set_clipboard_text('hello') d = get_httpretty_request_body(httpretty.last_request()) assert d['content'] == 'aGVsbG8=' assert d['contentType'] == 'plaintext'
def test_set_location(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/location') ) assert isinstance(driver.set_location(11.1, 22.2, 33.3), WebDriver) d = get_httpretty_request_body(httpretty.last_request()) assert abs(d['location']['latitude'] - 11.1) <= FLT_EPSILON assert abs(d['location']['longitude'] - 22.2) <= FLT_EPSILON assert abs(d['location']['altitude'] - 33.3) <= FLT_EPSILON
def test_start_activity(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/start_activity'), body='{"value": ""}' ) driver.start_activity('com.example.myapp', '.ExampleActivity') d = get_httpretty_request_body(httpretty.last_request()) assert d['appPackage'] == 'com.example.myapp' assert d['appActivity'] == '.ExampleActivity'
def test_lock_no_args(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/lock'), body='{"value": ""}' ) driver.lock() d = get_httpretty_request_body(httpretty.last_request()) assert len(d.keys()) == 1 assert d['sessionId'] == '1234567890'
def test_find_elements_by_android_data_matcher_no_value(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/elements'), body='{"value": []}' ) els = driver.find_elements_by_android_data_matcher() d = get_httpretty_request_body(httpretty.last_request()) assert d['using'] == '-android datamatcher' assert d['value'] == '{}' assert len(els) == 0
def test_set_clipboard_with_url(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/set_clipboard'), body='{"value": ""}' ) driver.set_clipboard(appium_bytes(str('http://appium.io/'), 'UTF-8'), ClipboardContentType.URL, 'label for android') d = get_httpretty_request_body(httpretty.last_request()) assert d['content'] == 'aHR0cDovL2FwcGl1bS5pby8=' assert d['contentType'] == 'url' assert d['label'] == 'label for android'
def test_find_elements_by_android_data_matcher(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/elements'), body='{"value": [{"element-6066-11e4-a52e-4f735466cecf": "element-id1"}, {"element-6066-11e4-a52e-4f735466cecf": "element-id2"}]}' ) els = driver.find_elements_by_android_data_matcher(name='title', args=['title', 'Animation']) d = get_httpretty_request_body(httpretty.last_request()) assert d['using'] == '-android datamatcher' value_dict = json.loads(d['value']) assert value_dict['args'] == ['title', 'Animation'] assert value_dict['name'] == 'title' assert els[0].id == 'element-id1' assert els[1].id == 'element-id2'
def test_open_notifications(self): driver = android_w3c_driver() httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/appium/device/open_notifications')) assert isinstance(driver.open_notifications(), WebDriver)
def test_get_contexts(self): driver = android_w3c_driver() httpretty.register_uri(httpretty.GET, appium_command('/session/1234567890/context'), body='{"value": "NATIVE"}') assert driver.current_context == 'NATIVE'
def test_clipboard_with_subsubclass(self): driver = self.android_w3c_driver(SubSubWebDriver) httpretty.register_uri(httpretty.GET, appium_command('/session/1234567890/context'), body='{"value": "NATIVE"}') assert driver.current_context == 'NATIVE'
def test_toggle_location_services(self): driver = android_w3c_driver() httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/appium/device/toggle_location_services') ) assert isinstance(driver.toggle_location_services(), WebDriver)