I ran in to a situation where sometimes clicking on a Submit button doesn't work in Selenium Webdriver. The same functionality could be obtained by pressing the Enter button.

Here, after entering the value in text box, I want Selenium WebDriver to press Enter key. How would I do that? I'm using 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归因
不隶属于 StackOverflow
scroll top