Simulates typing into the element. Use this to send simple key events or to fill out form fields. This can also be used to set file inputs. Args: value: A string for typing, or setting form fields. For setting file inputs, this could be a local f
(self, *value: str)
| 238 | return self._execute(Command.IS_ELEMENT_ENABLED)["value"] |
| 239 | |
| 240 | def send_keys(self, *value: str) -> None: |
| 241 | """Simulates typing into the element. |
| 242 | |
| 243 | Use this to send simple key events or to fill out form fields. |
| 244 | This can also be used to set file inputs. |
| 245 | |
| 246 | Args: |
| 247 | value: A string for typing, or setting form fields. For setting |
| 248 | file inputs, this could be a local file path. |
| 249 | |
| 250 | Examples: |
| 251 | To send a simple key event:: |
| 252 | |
| 253 | form_textfield = driver.find_element(By.NAME, "username") |
| 254 | form_textfield.send_keys("admin") |
| 255 | |
| 256 | or to set a file input field:: |
| 257 | |
| 258 | file_input = driver.find_element(By.NAME, "profilePic") |
| 259 | file_input.send_keys("path/to/profilepic.gif") |
| 260 | # Generally it's better to wrap the file path in one of the methods |
| 261 | # in os.path to return the actual path to support cross OS testing. |
| 262 | # file_input.send_keys(os.path.abspath("path/to/profilepic.gif")) |
| 263 | """ |
| 264 | # transfer file to another machine only if remote driver is used |
| 265 | # the same behaviour as for java binding |
| 266 | if self.parent._is_remote: |
| 267 | local_files = [ |
| 268 | self.parent.file_detector.is_local_file(str(keys_to_send)) |
| 269 | for keys_to_send in "".join(map(str, value)).split("\n") |
| 270 | ] |
| 271 | if None not in local_files: |
| 272 | remote_files = [] |
| 273 | for file in local_files: |
| 274 | remote_files.append(self._upload(file)) |
| 275 | value = tuple("\n".join(remote_files)) |
| 276 | |
| 277 | self._execute( |
| 278 | Command.SEND_KEYS_TO_ELEMENT, {"text": "".join(keys_to_typing(value)), "value": keys_to_typing(value)} |
| 279 | ) |
| 280 | |
| 281 | @property |
| 282 | def shadow_root(self) -> ShadowRoot: |
nothing calls this directly
no test coverage detected