Mimic 'Enter' Key Press in Selenium Web Test

I want to emulate Enter by clicking in Webtest. I am using Selenium 2.3.1. I want to do this using WebDriver. I know that we can do this using Selenium RC, but I do not want to do this. Has anyone done this before? I am open to switching to Selenium 2.20.0 (the latter).

+4
source share
1 answer

You can send the Enter key to an element. However, you cannot press Enter to, say, confirm the download dialog.

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 
+5
source

Source: https://habr.com/ru/post/1401722/


All Articles