如何按向下箭头键,然后按"Enter"键Selenium WebDriver中的按钮? [英] How to press Down Arrow key followed by "Enter" button in Selenium WebDriver?

查看:380
本文介绍了如何按向下箭头键,然后按"Enter"键Selenium WebDriver中的按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Selenium Java.我需要在文本框中输入值,然后按向下箭头选择建议,然后按Enter键.

I am using Selenium Java. I need to enter value into text box and press down arrow to select suggestions and then press Enter key.

所以,我的问题是如何按向下箭头键,然后按"Enter"键?

So, my question is how to press Down Arrow key followed by "Enter" key?

推荐答案

您可以导入密钥并使用它们.

You can import Keys and use these.

import org.openqa.selenium.Keys

WebElement.sendKeys(Keys.DOWN);
WebElement.sendKeys(Keys.RETURN);

修改

也可能在一个sendKeys()调用中使用

Could probably also be used in one sendKeys() call

WebElement.sendKeys(Keys.DOWN, Keys.RETURN);

这篇关于如何按向下箭头键,然后按"Enter"键Selenium WebDriver中的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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