element.sendKeys(Keys.ENTER) does not work for link

189 views
Skip to first unread message

Dmitry Katsubo

unread,
Feb 4, 2014, 12:58:12 PM2/4/14
to seleniu...@googlegroups.com
Hi everyone,

I am facing very strange problem, which Google keeps silence on. If element represents a link (<a>), then pressing Enter in browser on this link (link is focused) works fine, but when programmed explicitly in Selenium – it does not.

I have tried element.sendKeys(Keys.ENTER) and element.sendKeys(Keys.chord(Keys.ENTER)) with no result – the link is not "clicked".

element.click() works absolutely fine, but I need to test keyboard navigation (tabbing+enter). Maybe it has something to do with a focus?

Selenuim 2.39.0, FF v21.

Dmitry Katsubo

unread,
Feb 5, 2014, 4:55:17 AM2/5/14
to seleniu...@googlegroups.com
Somehow the following code worked fine for link:

new Actions(getWebDriver()).sendKeys(element, Keys.ENTER).build().perform();

but enter on input field still does not work. Javascript handler looks like this:

applicationNumberInput = $('input#searchAppNumber');

applicationNumberInput.on('keyup', function(e) {
    var keyCode = (e.keyCode ? e.keyCode : e.which);
    if (keyCode == $.ui.keyCode.ENTER) {
        ...
        return false;
    }
});
Reply all
Reply to author
Forward
0 new messages