How do I make the protractor press the ESCAPE key?
There could be several reasons for this, but first of all, according to the Protractor documentation, you need to execute sendKeys()
on ElementFinder
, so if focus is on, like an input field, you can do this
element(by.css('#-your-input-id')).sendKeys(protractor.Key.ESCAPE);
You can also do it on the body like this ( $
= transcript for by.css
):
$('body').sendKeys(protractor.Key.ESCAPE);
Second, there might be a problem with your web editor's UserInteraction API. There have been many issues in the past with Firefox and Safari drivers and some versions of Chromedriver.
Hope it helps
source to share
If you want to use the same code as yours, you can use this:
browser.actions().sendKeys(protractor.Key.ESC).perform();
I hope this works for you.
Since sendKeys and Key are implemented using the Keyboard class, the key values โโwill be different for the OS. May be.
The links below will list the names of the keys you must provide for sendKeys:
https://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm
https://autohotkey.com/docs/commands/Send.htm
Hope it helped.
source to share