使用Python和Selenium键入Enter/Return键 [英] Typing the Enter/Return key using Python and Selenium

查看:154
本文介绍了使用Python和Selenium键入Enter/Return键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆