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")) """ # transfer file to another machine only if remote driver is used # the same behaviour as for java binding if self.parent._is_remote: local_file = self.parent.file_detector.is_local_file(*value) if local_file is not None: value = self._upload(local_file) self._execute(Command.SEND_KEYS_TO_ELEMENT, {'text': "".join(keys_to_typing(value)), 'value': keys_to_typing(value)})
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")) """ # transfer file to another machine only if remote driver is used # the same behaviour as for java binding if self.parent._is_remote: local_file = self.parent.file_detector.is_local_file(*value) if local_file is not None: value = self._upload(local_file) self._execute(Command.SEND_KEYS_TO_ELEMENT, { 'text': "".join(keys_to_typing(value)), 'value': keys_to_typing(value) })
async def send_keys2(self, keys_str): value = (keys_str,) # setting file inputs is not yet supported, here is the old code: ''' if self.parent._is_remote: local_file = self.parent.file_detector.is_local_file(*value) if local_file is not None: value = self._upload(local_file) ''' di = { 'text': "".join(keys_to_typing(value)), 'value': keys_to_typing(value) } await self._execute2(Command.SEND_KEYS_TO_ELEMENT, di)
def send_keys(self, keys, log=True): """ Send keys to the page object. :param keys: keys to send to the page object :param bool log: whether to log or not (default is True) :type keys: iterable of string type :returns: self :rtype: PageObjectBase instance :raises NoSuchElementException: if the element cannot be found :raises InvalidSelectorException: if the selector is invalid or doesn't select an element """ single_keys = keys_to_typing(keys) if log: self.logger.info('sending keys {} to page object {}'.format( single_keys, self._log_id_short)) self.logger.debug('sending keys {} to page object; {}'.format( single_keys, self._log_id_long)) self.webelement.send_keys(keys) if log: self.logger.info('sent keys {} to page object {}'.format( single_keys, self._log_id_short)) self.logger.debug('sent keys {} to page object; {}'.format( single_keys, self._log_id_long)) return self
def send_keys(self, keysToSend): """ Send Keys to the Alert. :Args: - keysToSend: The text to be sent to Alert. """ self.driver.execute(Command.W3C_SET_ALERT_VALUE, { 'value': keys_to_typing(keysToSend), 'text': keysToSend })
def is_local_file(self, *keys): file_path = ''.join(keys_to_typing(keys)) if not file_path: return None try: if os.path.isfile(file_path): return file_path except Exception: pass return None
def send_keys(self, keysToSend): """ Send Keys to the Alert. :Args: - keysToSend: The text to be sent to Alert. """ if self.driver.w3c: self.driver.execute(Command.W3C_SET_ALERT_VALUE, {'value': keys_to_typing(keysToSend)}) else: self.driver.execute(Command.SET_ALERT_VALUE, {'text': keysToSend})
def send_keys(self, *value: str) -> T: """Simulates typing into the element. Args: value (str): A string for typing. Returns: `appium.webdriver.webelement.WebElement` """ keys = keys_to_typing(value) self._execute(RemoteCommand.SEND_KEYS_TO_ELEMENT, { 'text': ''.join(keys), 'value': keys }) return self
def send_keys_slowly(self, *value): value_as_keys = keys_to_typing(value) for v in value_as_keys[:-1]: self.send_keys(v) humanlike_pauses.inter_key_delay() self.send_keys(value_as_keys[-1])