10 examples of 'how to press enter in selenium' in Python

Every line of 'how to press enter in selenium' 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
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()
292def type_keys(self, *args):
293 self.click()
294 self.clear()
295 self.send_keys(*args)
702@CompatibleMethod
703def SendEnter(self):
704 logger.step_normal("Element [%s]: SendEnter()" % self.__name__, )
705
706 self.__wait()
707 elements = Browser.RunningBrowser.find_elements(self.by, self.value)
708
709 action = webdriver.ActionChains(Browser.RunningBrowser)
710 action.send_keys_to_element(elements[self.index], Keys.ENTER)
711 action.perform()
319def tap_enter(self):
320 self.switch_to_keyboard()
321 self._tap(self._enter_key)
322 self.apps.switch_to_displayed_app()
424def press_enter(self):
425 return self.send_keys(Keys.ENTER)
198def _tap_page_switching_key(self, val):
199 locator = (self._page_switching_key_locator[0], self._page_switching_key_locator[1] % val)
200 key = Wait(self.marionette).until(expected.element_present(*locator))
201 Wait(self.marionette).until(expected.element_displayed(key))
202 Actions(self.marionette).press(key).release().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.
603
604
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.
607
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.
612
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.
615
616
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,])
81def pressTest(self, key):
82 print( "-> Pressing " + key.upper() )
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)
374def shift_key_up(self):
375 """
376 Release the shift key.
377
378 """
379 self.do_command("shiftKeyUp", [])

Related snippets