Re: How to simulate Enter key press event using JavaScript

5,591 views
Skip to first unread message

Szymon Rapacki

unread,
Oct 1, 2012, 8:37:00 AM10/1/12
to seleniu...@googlegroups.com
I had similiar problem. My solution was that in JavaScript "Keys.Return" is the same as Enter, so I use: 

new Actions(driver).sendKeys(Keys.RETURN).build().perform();
but it is possible that in your code below code shoudl work:

driver.findElement(By.cssSelector("xxxxxxxx")).sendKeys(Keys.RETURN) 

-- 
Regards
Symon
 
W dniu poniedziałek, 1 października 2012 02:01:55 UTC+2 użytkownik Anu napisał:
Hi,
In my application, Inside iFrame there is a textbox , After entering text i need to click on Enter key using selenium. I tried
driver.findElement(By.cssSelector("xxxxxxxx")).sendKeys(Keys.ENTER) and even this is not working (jse.executeScript("document.getElementById('xxxx').click();");) as it performs click operation. Could someone help me on how to simulate Enter key press event using Javascript.

Thanks
Anu

Simon Stewart

unread,
Oct 3, 2012, 9:55:53 AM10/3/12
to seleniu...@googlegroups.com
"Keys.ENTER" is the small enter key on the number pad. "Keys.RETURN"
is the main return key on the body of the keyboard. It's pretty common
for people to refer to "return" as "enter", which leads to confusion
like this.

Simon
> --
> You received this message because you are subscribed to the Google Groups
> "Selenium Users" group.
> To post to this group, send email to seleniu...@googlegroups.com.
> To unsubscribe from this group, send email to
> selenium-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/selenium-users/-/IJkbuMinb4MJ.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Mike Riley

unread,
Oct 10, 2012, 2:18:30 PM10/10/12
to seleniu...@googlegroups.com
Not just people.  On most keyboards these days they are both labeled as "Enter" (both my laptop and my Proliant server are that way).  When I tell people to hit Return I usually get a blank stare or am asked where that key is on the keyboard, because they have never seen such a key.  ;)

Mike
Message has been deleted

code solver

unread,
Sep 24, 2013, 3:00:01 PM9/24/13
to seleniu...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages