使用Python和Selenium输入Enter/Return键? [英] Typing Enter/Return key using Python and Selenium?
问题描述
我正在寻找一种在Selenium中键入和Enter或Return键的快速方法.不幸的是,我要测试的表单(不是我自己的代码,所以我无法修改)没有提交"按钮.手动使用它时,只需键入 ENTER 或 RETURN .我需要知道如何使用Selenium type
命令来执行此操作,因为没有单击按钮.
I'm looking for a quick way to type and Enter or Return key in Selenium. 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. I need to know how to 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 a different, for example python: from selenium.webdriver.common.keys import Keys
这篇关于使用Python和Selenium输入Enter/Return键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!