在 Selenium 中键入 Enter/Return 键 [英] Typing the Enter/Return key in Selenium

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

问题描述

我正在寻找一种在 Selenium 中快速键入 EnterReturn 键的方法.

I'm looking for a quick way to type the Enter or Return key in Selenium.

不幸的是,我要测试的表单(不是我自己的代码,所以我无法修改)没有 Submit 按钮.手动使用它时,我只需键入 EnterReturn.由于没有可单击的按钮,如何使用 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

这篇关于在 Selenium 中键入 Enter/Return 键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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