10 examples of 'send keys selenium python' in Python

Every line of 'send keys selenium python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
292def type_keys(self, *args):
293 self.click()
294 self.clear()
295 self.send_keys(*args)

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

218def key_down(self,locator,keycode):
219 """
221 Simulates a user pressing a key (without releasing it yet).
224 'locator' is an element locator
225 'keycode' is the numeric keycode of the key to be pressed, normally the
226 ASCII value of that key.
227 """
228 self.do_command("keyDown", [locator,keycode,])
374def shift_key_up(self):
375 """
376 Release the shift key.
378 """
379 self.do_command("shiftKeyUp", [])
150def test_send_keys():
151 find = MockFinder()
152 interact = Interactor(None, find, None, None, None)
153 page_element = PageElement(By.ID, "test-id")
155 interact.send_keys(page_element, Keys.ARROW_LEFT)
157 assert_that(find.mock_element.text, equal_to(""), "Key not sent to element correctly")
138def select_element_and_press_key(driver, element, key, press_number=1):
139 actions = ActionChains(driver)
140 actions.move_to_element(element)
141 actions.click()
142 for i in range(press_number):
143 actions = ActionChains(driver)
144 actions.send_keys_to_element(element, key)
145 actions.perform()
600def type_keys(self,locator,value):
601 """
602 Simulates keystroke events on the specified element, as though you typed the value key-by-key.
605 This is a convenience method for calling keyDown, keyUp, keyPress for every character in the specified string;
606 this is useful for dynamic UI widgets (like auto-completing combo boxes) that require explicit key events.
608 Unlike the simple "type" command, which forces the specified value into the page directly, this command
609 may or may not have any visible effect, even in cases where typing keys would normally have a visible effect.
610 For example, if you use "typeKeys" on a form element, you may or may not see the results of what you typed in
611 the field.
613 In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to
614 send the keystroke events corresponding to what you just typed.
617 'locator' is an element locator
618 'value' is the value to type
619 """
620 self.wait_for_element_present(locator)
621 self.do_command("typeKeys", [locator,value,])
32def send_keys(self, page_name, locator, text):
33 """
34 调用输入法输入
35 :param page_name: 页面元素
36 :param locator: 元素名称
37 :param text: 输入内容
38 :return:
39 """
40 self.D.get(self.p.get_type(page_name, locator)).send_keys(text)
178def press_keys(self, keys, **kwargs):
179 for key in keys:
180 self.press_key(key, **kwargs)
121def send_keys(self, text):
122 """
123 Input text
125 Refs:
126 https://github.com/Tencent/FAutoTest/blob/58766fcb98d135ebb6be88893d10c789a1a50e18/fastAutoTest/core/h5/h5PageOperator.py#L40
127 http://compatibility.remotedebug.org/Input/Chrome%20(CDP%201.2)/commands/dispatchKeyEvent
128 """
129 for c in text:
130 self._call("Input.dispatchKeyEvent", type="char", text=c)
974def sendKey(self, keychr):
975 """Send one character with no modifiers."""
976 return self._sendKey(keychr)

Related snippets