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

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

问题描述

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

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