"UnsupportedOperationError: sendKeysToActiveElement" error when running 'keyDown(protractor.Key.CONTROL)'
ariel0058 opened this issue · comments
Hi there!
I've been spent days trying to figure out how to correctly perform a 'ctrl + click' action in protractor tests, but I'm always getting error UnsupportedOperationError: sendKeysToActiveElement, From: Task: keyDown
. Looks like keyDown(protractor.Key.CONTROL)
is not supported with newer version browsers? I did some research online, latest post about perform 'ctrl+click' in protractor dates back to 2019, and none of the solutions there work for me...T T
I really appreciate any suggestion/help! thank you so much :)
Bug report
- Node Version:
v10.22.0
- Protractor Version:
7.0.0
- Angular Version: ``
- Browser(s):
Firefox Version 90.0.818.46
andChrome Version 90.0.4430.85
- Operating System and Version
Windows 10 pro 64bit
- Your protractor configuration file
- A relevant example test: I try to perform 'ctrl+click' action for rows in table by using following code
browser.actions() .mouseMove(this.getRow(rowNumber).siteId) .keyDown(protractor.Key.CONTROL) .click() .keyUp(protractor.Key.CONTROL) .perform();
- Output from running the test:
Message: Failed: sendKeysToActiveElement Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53' System info: host: 'xxx2160', ip: 'xx.xx.xx.xx', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '16' Driver info: driver.version: unknown Stack: UnsupportedOperationError: sendKeysToActiveElement Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53' System info: host: 'xxx2160', ip: 'xx.xx.xx.xx', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '16' Driver info: driver.version: unknown at Object.checkLegacyResponse (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:546:15) at parseHttpResponse (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13) at doSend.then.response (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:441:30) at process._tickCallback (internal/process/next_tick.js:68:7) From: Task: keyDown at thenableWebDriverProxy.schedule (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:807:17) at actions.map.action (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\actions.js:124:23) at Array.map (<anonymous>) at C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\actions.js:123:29 at TaskQueue.execute_ (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14) at TaskQueue.executeNext_ (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27) at asyncRun (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2927:27) at C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:668:7 at process._tickCallback (internal/process/next_tick.js:68:7) From: Task: ActionSequence.perform
- Steps to reproduce the bug
- The URL you are running your tests against (if relevant):
protractor protractor-test.conf.js
This is due to unsupported action on browser with w3c enabled by default.
Here is workaround:
@StanislavKharchenko Thanks for your response! I tried the workaround, it doesn't seem to work for me. Would you be able to take a look? Thanks :)
Attemp1
config:
multiCapabilities: [
{
'goog:chromeOptions': { //disable w3c here
w3c: false
},
'browserName': 'chrome',
'chromeOptions': {
'args': [
'incognito',
"--headless",
"--disable-gpu",
"--window-size=1280,960"
],
'prefs': {
'browser': {
'set_download_behavior': { behavior: 'allow' }
},
'download': {
'prompt_for_download': false,
'directory_upgrade': true,
'default_directory': downloadDir
},
},
},
}
]
error message:
E/launcher - SessionNotCreatedError: Unable to create session from {
"desiredCapabilities": {
"count": 1,
"browserName": "chrome",
"chromeOptions": {
"args": [
"incognito",
"--headless",
"--disable-gpu",
"--window-size=1280,960"
],
"prefs": {
"download": {
"prompt_for_download": false,
"directory_upgrade": true
},
"browser": {
"set_download_behavior": {
"behavior": "allow"
}
}
}
},
"goog:chromeOptions": {
"w3c": false
}
},
"capabilities": {
"firstMatch": [
{
"browserName": "chrome",
"goog:chromeOptions": {
"w3c": false
}
}
]
}
}
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'xxx2160', ip: 'xx.xx.xx.xx', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '16'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
at Function.createSession (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\chrome.js:761:15)
at createDriver (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:170:33)
at Builder.build (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:626:16)
at Local.getNewDriver (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\built\driverProviders\driverProvider.js:53:33)
at Runner.createBrowser (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\built\runner.js:195:43)
at q.then.then (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\built\runner.js:339:29)
at _fulfilled (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30
at Promise.promise.promiseDispatch (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
Attemp2
config:
multiCapabilities: [
{
'browserName': 'chrome',
'goog: chromeOptions': { //disable w3c here
w3c: false,
'args': [
'incognito',
"--headless",
"--disable-gpu",
"--window-size=1280,960"
],
'prefs': {
'browser': {
'set_download_behavior': { behavior: 'allow' }
},
'download': {
'prompt_for_download': false,
'directory_upgrade': true,
'default_directory': downloadDir
},
},
},
}]
error message:
(node:18468) UnhandledPromiseRejectionWarning: UnsupportedOperationError: sendKeysToActiveElement
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'xxx2160', ip: 'xx.xx.xx.xx', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '16'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: keyDown
at thenableWebDriverProxy.schedule (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
at actions.map.action (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\actions.js:124:23)
at Array.map (<anonymous>)
at C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\actions.js:123:29
at TaskQueue.execute_ (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at C:\Users\azao\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:18468) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch
block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:18468) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:18468) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
Just change chromeOptions to 'goog:chromeOptions' in your config and place w3c: false here.
Like:
multiCapabilities: [
{
'browserName': 'chrome',
'goog:chromeOptions': {
'args': [
'incognito',
"--headless",
"--disable-gpu",
"--window-size=1280,960"
],
'prefs': {
'browser': {
'set_download_behavior': { behavior: 'allow' }
},
'download': {
'prompt_for_download': false,
'directory_upgrade': true,
'default_directory': downloadDir
},
},
w3c: false
}
}
]
Thanks!! @StanislavKharchenko by using your suggested config, I'm still getting the UnhandledPromiseRejectionWarning: UnsupportedOperationError: sendKeysToActiveElement
tho...
I have no idea why...
Does any other browser actions works with your app? Like mouseMove?
mouseMove works for me fine(following code works). The UnhandledPromiseRejectionWarning: UnsupportedOperationError: sendKeysToActiveElement will appear once I use keyDown or sendKey inside the actions function.
browser.actions()
.mouseMove(this.getRow(rowNumber).siteId)
//.keyDown(protractor.Key.CONTROL)
.click()
//.keyUp(protractor.Key.CONTROL)
.perform();
It seems that Protractor doesn’t handle these browser events properly.
I suggest to ask in stackoverflow, there more users from Protractor and native selenium-webdriver community. Unfortunately, Protractor maintainers in @angular team totally ignore any users issues and even ignore comments. They also decided to deprecate and neglect project after a year total ignoring...
Thanks anyway👍 @StanislavKharchenko