[英]mimic 'Enter' Key press in Webtest using Selenium
I want to mimic Enter being pressed in Webtest. 我想模仿在Webtest中按Enter键。 I am using Selenium 2.3.1.
我正在使用Selenium 2.3.1。 I want to do it using WebDriver.
我想用WebDriver做到这一点。 I know that we can do this using Selenium RC, but I do not want to do it that way.
我知道我们可以使用Selenium RC来做到这一点,但我不想这样做。 Has anybody done this before?
有没有人这样做过? I am open to upgrade to Selenium 2.20.0 (latest).
我愿意升级到Selenium 2.20.0(最新版)。
You can send an Enter key to an element. 您可以将Enter键发送到元素。 However, you can't press Enter to, say, confirm a download dialog.
但是,您无法按Enter键,例如确认下载对话框。
WebElement elem = driver.findElement(By.id("damnit")); // obtain an element
elem.sendKeys(org.openqa.selenium.Keys.ENTER); // this sends an Enter key to the element
elem.sendKeys("hey" + org.openqa.selenium.Keys.ENTER); // this writes and then confirms by Enter
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.