コード例 #1
0
ファイル: network_test.py プロジェクト: appium/python-client
 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)
コード例 #2
0
ファイル: keyboard_test.py プロジェクト: appium/python-client
 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)
コード例 #3
0
    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
コード例 #4
0
ファイル: lock_test.py プロジェクト: Jonahss/python-client
 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
コード例 #5
0
ファイル: context_test.py プロジェクト: Jonahss/python-client
 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'
コード例 #6
0
ファイル: settings_test.py プロジェクト: appium/python-client
 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'
コード例 #7
0
 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
コード例 #8
0
 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'
コード例 #9
0
ファイル: network_test.py プロジェクト: appium/python-client
 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
コード例 #10
0
 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'
コード例 #11
0
ファイル: gsm_test.py プロジェクト: appium/python-client
    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
コード例 #12
0
ファイル: settings_test.py プロジェクト: appium/python-client
    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'
コード例 #13
0
ファイル: network_test.py プロジェクト: appium/python-client
    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
コード例 #14
0
ファイル: power_test.py プロジェクト: Jonahss/python-client
    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
コード例 #15
0
ファイル: power_test.py プロジェクト: Jonahss/python-client
    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
コード例 #16
0
    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'
コード例 #17
0
ファイル: gsm_test.py プロジェクト: appium/python-client
    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
コード例 #18
0
ファイル: network_test.py プロジェクト: appium/python-client
    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
コード例 #19
0
ファイル: location_test.py プロジェクト: appium/python-client
 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
コード例 #20
0
ファイル: lock_test.py プロジェクト: Jonahss/python-client
    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
コード例 #21
0
ファイル: gsm_test.py プロジェクト: appium/python-client
    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
コード例 #22
0
ファイル: app_test.py プロジェクト: Jonahss/python-client
    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)
コード例 #23
0
    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
コード例 #24
0
    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'
コード例 #25
0
ファイル: location_test.py プロジェクト: appium/python-client
    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
コード例 #26
0
    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'
コード例 #27
0
ファイル: lock_test.py プロジェクト: Jonahss/python-client
    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'
コード例 #28
0
    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
コード例 #29
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'
コード例 #30
0
    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'
コード例 #31
0
ファイル: common_test.py プロジェクト: zsk1993/python-client
 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)
コード例 #32
0
 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'
コード例 #33
0
 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'
コード例 #34
0
 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)