使用Python和Selenium键入Enter/Return键 [英] Typing the Enter/Return key using Python and Selenium
问题描述
我正在寻找一种在Selenium中键入 Enter 或 Return 键的快捷方法.
I'm looking for a quick way to type the Enter or Return key in Selenium.
不幸的是,我要测试的表单(不是我自己的代码,所以我无法修改)没有 Submit 按钮.手动使用它时,只需键入 Enter 或 Return .由于没有单击按钮,我如何使用Selenium type
命令来做到这一点?
Unfortunately, the form I'm trying to test (not my own code, so I can't modify) doesn't have a Submit button. When working with it manually, I just type Enter or Return. How can I do that with the Selenium type
command as there is no button to click?
推荐答案
import org.openqa.selenium.Keys
WebElement.sendKeys(Keys.RETURN);
import
语句适用于Java.对于其他语言,可能有所不同.例如,在Python中,它是from selenium.webdriver.common.keys import Keys
The import
statement is for Java. For other languages, it is maybe different. For example, in Python it is from selenium.webdriver.common.keys import Keys
这篇关于使用Python和Selenium键入Enter/Return键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!