示例#1
0
    def create_web_element(self, element_id):
        """
		Creates a web element with the specified element_id.
		Overrides method in Selenium WebDriver in order to always give them
		Appium WebElement
		"""
        return MobileWebElement(self, element_id)
示例#2
0
    def create_web_element(self, element_id):
        """
		Creates a web element with the specified element_id.
		Overrides method in Selenium WebDriver in order to always give them
		Appium WebElement
		"""
        #self.logger.log("[action]create_web_element(element_id='%s')" %element_id)
        return MobileWebElement(self, element_id)
示例#3
0
    def test_send_key(self):
        driver = android_w3c_driver()
        httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/element/element_id/value'))

        element = MobileWebElement(driver, 'element_id', w3c=True)
        element.send_keys('happy testing')

        d = get_httpretty_request_body(httpretty.last_request())
        assert d['text'] == ''.join(d['value'])
示例#4
0
    def test_set_value(self):
        driver = android_w3c_driver()
        httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/appium/element/element_id/value'))

        element = MobileWebElement(driver, 'element_id', w3c=True)
        value = 'happy testing'
        element.set_value(value)

        d = get_httpretty_request_body(httpretty.last_request())
        assert d['value'] == [value]
示例#5
0
    def test_find_element_by_windows_uiautomation(self):
        driver = android_w3c_driver()
        element = MobileWebElement(driver, 'element_id', w3c=True)
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/element/element_id/element'),
            body='{"value": {"element-6066-11e4-a52e-4f735466cecf": "win-element-id"}}'
        )
        el = element.find_element_by_windows_uiautomation('win_element')

        d = get_httpretty_request_body(httpretty.last_request())
        assert d['using'] == '-windows uiautomation'
        assert el.id == 'win-element-id'
示例#6
0
    def test_find_elements_by_android_data_matcher_no_value(self):
        driver = android_w3c_driver()
        element = MobileWebElement(driver, 'element_id', w3c=True)
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/element/element_id/elements'),
            body='{"value": []}')
        els = element.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
示例#7
0
    def test_send_key_with_file(self):
        driver = android_w3c_driver()
        # Should not send this file
        tmp_f = tempfile.NamedTemporaryFile()
        httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/element/element_id/value'))

        try:
            element = MobileWebElement(driver, 'element_id', w3c=True)
            element.send_keys(tmp_f.name)
        finally:
            tmp_f.close()

        d = get_httpretty_request_body(httpretty.last_request())
        assert d['text'] == ''.join(d['value'])
示例#8
0
    def test_get_attribute_with_dict(self):
        driver = android_w3c_driver()
        rect_dict = {'y': 200, 'x': 100, 'width': 300, 'height': 56}
        httpretty.register_uri(
            httpretty.GET,
            appium_command('/session/1234567890/element/element_id/attribute/rect'),
            body=json.dumps({"value": rect_dict}),
        )

        element = MobileWebElement(driver, 'element_id', w3c=True)
        ef = element.get_attribute('rect')

        d = httpretty.last_request()

        assert isinstance(ef, dict)
        assert ef == rect_dict
示例#9
0
    def test_find_elements_by_android_data_matcher(self):
        driver = android_w3c_driver()
        element = MobileWebElement(driver, 'element_id', w3c=True)
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/element/element_id/elements'),
            body='{"value": [{"element-6066-11e4-a52e-4f735466cecf": "child-element-id1"}, {"element-6066-11e4-a52e-4f735466cecf": "child-element-id2"}]}'
        )
        els = element.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 == 'child-element-id1'
        assert els[1].id == 'child-element-id2'