`Keys` is not defined when using `keyDown` action
See original GitHub issueWhen trying to create a test which checks the result of an option
+ click()
event in my app, Keys is not defined
.
This is the test being run (apologies if the JS looks malformed, it’s converted from CoffeeScript):
var driver = new webdriver.Builder()
.usingServer('http://localhost:4444/wd/hub')
.withCapabilities(webdriver.Capabilities.chrome()).build()
driver.manage().timeouts().setScriptTimeout(30000)
var ptor = protractor.wrapDriver(driver)
it('opens new tab with OPTION+click', function() {
ptor.keyDown(Keys.ALT)
.then(function() {
ptor.findElement(protractor.By.repeater('item in ses.items').row(4).column("{{item.subject}}")).click();
ptor.keyUp(Keys.ALT);
})
ptor.findElements(protractor.By.repeater('item in ses.navItems'));
.then(function(tabs) {
expect(tabs.length).toBe(1);
});
});
I’ve also tried the following variations for Keys.ALT
: ptor.driver.Keys.ALT
, ptor.driver.Key.ALT
, and Key.ALT
It’s entirely possible I’m not writing this test correctly. If that’s the case I’d appreciate any pointers in testing clicks with key modifiers.
Issue Analytics
- State:
- Created 10 years ago
- Comments:19 (2 by maintainers)
Top Results From Across the Web
JavaScript Game KeyDown event & keyboard actions not ...
//player (keyboard) input var keysDown= {}; document.addEventListener("keyDown", function(e) { console.log('key press'); keysDown[e. ... keyCode] ...
Read more >Element: keydown event - Web APIs | MDN
The keydown event is fired when a key is pressed. Unlike the deprecated keypress event, the keydown event is fired for all keys, ......
Read more >Keyboard: keydown and keyup
Pressing a key always generates a keyboard event, be it symbol keys or special keys like Shift or Ctrl and so on. The...
Read more >Control.KeyDown Event (System.Windows.Forms)
KeyCode != Keys.Back) { // A non-numerical keystroke was pressed. // Set the flag to true and evaluate in KeyPress event. nonNumberEntered =...
Read more >.keydown() | jQuery API Documentation
To determine which key was pressed, examine the event object that is passed to the handler function. While browsers use differing properties to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Maybe I am not getting it… I am trying to get one Enter click but it just doesn’t working.
I also get Keys is not defined. What is the good way of getting one enter click?
Thank you all for your help i now got it working
i made a little change and i now got it working with this :
var search = element(by.id(‘possearch_00A’)); search.sendKeys(‘+tegoedbon’,protractor.Key.ENTER);
because it can now use sendKeys you can just send the ENTER aswell 😃