[英]How to trigger Enter Key Function in Webdriver?
I ran in to a situation where sometimes clicking on a Submit button doesn't work in Selenium Webdriver. 我遇到了有时在Selenium Webdriver中单击“提交”按钮不起作用的情况。 The same functionality could be obtained by pressing the Enter button.
通过按Enter键可以获得相同的功能。
Here, after entering the value in text box, I want Selenium WebDriver to press Enter key. 在这里,在文本框中输入值后,我希望Selenium WebDriver按Enter键。 How would I do that?
我该怎么做? I'm using java
我正在使用Java
driver.findElement(By.id("email")).clear();
driver.findElement(By.id("email")).sendKeys("testing@netexam.com");
Thanks in advance! 提前致谢!
Try this: 尝试这个:
driver.findElement(By.id("email")).clear();
driver.findElement(By.id("email")).sendKeys("testing@netexam.com");
driver.findElement(By.id("email")).sendKeys(Keys.RETURN); //Send Enter Key
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.