My Protractor tests that use sendKeys to press Enter or Tab failed today after I was auto-updated to Chrome 76.
This worked find yesterday on Chrome 75.
This is the code that used to work:
browser.actions().sendKeys(protractor.Key.TAB).perform();
The error message is
Failed: sendKeysToActiveElement
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'DESKTOP-6JGLC4V', ip: '192.168.0.5', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_221'
Driver info: driver.version: unknown
Our Angular application has drop-down menus where you have to click outside of the drop-down or press the Tab key to close it. So I'm not sending the key stroke to an input element. I've tried $('body').sendKeys(protractor.Key.TAB);
but that doesn't seem to work.
This error message...
Failed: sendKeysToActiveElement
...implies that the ChromeDriver was unable to invoke sendKeys()
to the ActiveElement.
This issue started to surface when ChromeDriver / Chrome switched over to W3C support.
@AutomatedTester in the discussion UnsupportedOperationError: sendKeysToActiveElement with sendkeys mentions, this may be an issue within the Actions class within the Client bindings.
There should be a little shim in the bindings that make sure the same functionality is given on older commands that have been removed. This has been implemented in the core selenium binding.
The Python example:
def send_keys(self, *keys_to_send):
"""
Sends keys to current focused element.
:Args:
- keys_to_send: The keys to send. Modifier keys constants can be found in the
'Keys' class.
"""
typing = keys_to_typing(keys_to_send)
if self._driver.w3c:
for key in typing:
self.key_down(key)
self.key_up(key)
else:
self._actions.append(lambda: self._driver.execute(
Command.SEND_KEYS_TO_ACTIVE_ELEMENT, {'value': typing}))
return self
def send_keys_to_element(self, element, *keys_to_send):
"""
Sends keys to an element.
:Args:
- element: The element to send keys.
- keys_to_send: The keys to send. Modifier keys constants can be found in the
'Keys' class.
"""
self.click(element)
self.send_keys(*keys_to_send)
return self
@barancev have already merged the required changes through the commit Renaming back 'py' directory, use of 'legacy_create_init' argument and this issue would get completely resolved with the next release of ChromeDriver v77.0 / Chrome v77.0.
The good news is ChromeDriver v77.0 is already released containing the following fixes. From the Release Notes of ChromeDriver v77.0:
Protractor.Key.Enter is not working in ChromeDriver v75.0.3770.8
Upgraded to chromeDriver 77 and still running into the same issue as mentioned above.
await elem.sendKeys(protractor.Key.TAB);
also tried: await browser.actions().sendKeys(protractor.Key.TAB).perform();
`- Failed: sendKeysToActiveElement
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'GC02XYZ...', ip: 'fe80:xyz...', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '11.0.1'
Driver info: driver.version: unknown`
`chromeDriver -v
ChromeDriver 77.0.3865.40`
When using chrome 74+ please add the below at configuration.js file
exports.config = {
seleniumAddress : 'http://localhost:4444/wd/hub',
specs: ['spec.js'],
capabilities:{
'browserName': 'chrome',
'goog:chromeOptions': {
w3c: false
}
}
};
Notes: refer the this link https://github.com/angular/protractor/issues/5274#issuecomment-522258213
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With