Example #1
0
    def send_keys(self, *value):
        """Simulates typing into the element.

        :Args:
            - value - A string for typing, or setting form fields.  For setting
              file inputs, this could be a local file path.

        Use this to send simple key events or to fill out form fields::

            form_textfield = driver.find_element_by_name('username')
            form_textfield.send_keys("admin")

        This can also be used to set file inputs.

        ::

            file_input = driver.find_element_by_name('profilePic')
            file_input.send_keys("path/to/profilepic.gif")
            # Generally it's better to wrap the file path in one of the methods
            # in os.path to return the actual path to support cross OS testing.
            # file_input.send_keys(os.path.abspath("path/to/profilepic.gif"))

        """
        WE.send_keys(self, *value)
        return self
Example #2
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'])
Example #3
0
 def ie(self, element: WebElement, is_sent_keys: bool, value=None):
     if is_sent_keys and value is not None:
         logger.info(f'typing on {element} with {value}')
         element.send_keys(value)
     elif is_sent_keys is False:
         logger.info(f'clicking on {element}')
         element.click()
     else:
         raise ValueError('invalid values for function')
Example #4
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'])
 def send_keys(el: WebElement, data: str):
     el.click()
     el.send_keys(data)