Open vipul23394 opened 5 years ago
I am unable to use browser.actions().sendKeys(protractor.Key.ENTER).perform(); this code via using CMD command but when i am using through it will working as expected.
hi @vipul23394,
There are few legacy API like (sendKeysToActiveElement) deprecated from chrome 75. You can try using like this
driver.findElement(By.cssSelector("[name=\"q\"]")).sendKeys("q" + Keys.ENTER);
Thanks!
@Harsha509 I believe I am also running into a related issue. My browser auto-updated to Chrome 76 and now browser.actions().sendKeys(protractor.Key.TAB).perform(); doesn't work in my Protractor tests. Here's the link to the Stackoverflow issue I wrote up yesterday.
Our 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 really sending the key stroke to an element. I've tried $('body').sendKeys(protractor.Key.TAB); but that doesn't seem to work.
Any help is greatly appreciated!
@Harsha509 I have the exact same issue. I find it puzzling as to why would support for browser actions is removed, as it is guaranteed to break someone's work. Furthermore, there are cases where you cannot type directly to a control and would like to have the option to type 'blindly' to current element in focus.
Hi @DorHajaj11 , These changes are from chrome browsers and not from protractor/selenium. Inorder to use these you have to migrate to selenium 4, or downgrade to chrome 74.
@jmutidjo , you can use element(by.css('body')).click(); to make drop down to disappear.
Thanks!
@Harsha509 element(by.css('body')).click(); worked to make the drop down disappear. Thank you very much!
@Harsha509 Thanks for your reply. I understand it's from chrome api, but something like this can be a deciding factor on whether to even use protractor,selenium or anything that works with a webdriver and subjected to decisions chrome developers make which might not be good for test automation developers. So, I use protractor(5.4.2), what should I do? downgrading the browser is not easy because the auto update keeps upgrading it back to 76(despite the services are disabled - after a restart they are enabled again)
Hi @DorHajaj11 ,
Yes, they should have foresee before implementing this. But sadly no one expected this.
Actions API have some issues with chrome 75+ browsers with selenium. But few changes can be done in code level to make existing script to work.
If you’re using chrome 76 , use webdriver-manager@12.1.6 it will download chrome 76 driver. If you’ve any actions API implementation we can make few workarounds to make it work.
Happy to help
Thanks!
@Harsha509 Hi,
So today we have updated chrome to v76 and so webdriver-manager and keyDown is making trouble.
I need to perform left mouse click while holding control, because it's how feature works. How can i perform it without browser action keyDown(protractor.Key.CONTROL)?
Do you know if it gonna be fixed from chrome side?
Try disabling w3c which is default set to true starting Chrome 75
'goog:chromeOptions': { w3c: false }
hi @Panier,
Thanks @vsravuri for the solution.
Yes, enabling the below capability enables chrome to use legacy API. Please try it works. 'goog:chromeOptions': { w3c: false }
Thanks !
Hi @vsravuri and @Harsha509
I am facing the similar issue in Microsoft Edge Browser with latest version: 18.17763
My protractor test case in Microsoft Edge browser has been failed due to this error UnsupportedOperationError: sendKeysToActiveElement
How do i disable w3c for edge browser ?
Note: I have set the w3c flag as false in edge capabilities. That didn't work. I believe there is some other way to disable w3c for edge browser.
Could you please help me if you know the solution for this issue in edge browser ?
Thanks, Harshavardhan K
@Harsha509 @vsravuri I tired your solution of 'goog:chromeOptions': { w3c: false } it works perfectly fine, but it turns off headless mode. I wanted to achieve this in headless mode, do you have solution for it.
Anyone can please help in this.
Disabling the w3c fixed this issue sendKeysToActiveElement
.
In beta versions for chrome - 91.0.4472.27 with w3c disabled, getAttribute('value')
function is returning "null". Discussion is here
Any workaround apart from disabling w3c?
Looks it could be a big problem in the nearest future. @angular team, @kyliau Could you please look at this? With release of chrome 91 we will have broken Protractor tests.
Can you reanimate Protractor v6 or something with Selenium 4 treatment? Please don;t ignore community.
If in your case W3C disabling is not an option or doesn't work, you can rewrite the function and use plain javascript :
static async getInputValue(elementFinder: ElementFinder): Promise<string> {
return browser.executeScript(`return arguments[0].value`, elementFinder);
}
Not the best option I know...
You may have used also textToBePresentInElementValue
in this case:
import { falseIfMissing } from 'protractor/built/util';
private static textToBePresentInElementValue(elementFinder: ElementFinder, text: string) {
let hasText = async () => {
return browser.executeScript(`return arguments[0].value`, elementFinder).then((actualText: string) => {
return actualText.indexOf(text) > -1;
}, falseIfMissing);
};
return protractor.ExpectedConditions.and(protractor.ExpectedConditions.presenceOf(elementFinder), hasText);
}
Hi there!
Thanks for submitting an issue to Protractor.
To help us help you better, please do the following before submitting an issue:
http://www.protractortest.org/testapp
which you can use for the reproducible test case.Bug report
Feature Request Stack: UnsupportedOperationError: sendKeysToActiveElement Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53' System info: host: 'EPL-80', ip: '192.168.5.88', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181' Driver info: driver.version: unknown at Object.checkLegacyResponse (E:\js\Easypolicy\node_modules\selenium-webdriver\lib\error.js:546:15) at parseHttpResponse (E:\js\Easypolicy\node_modules\selenium-webdriver\lib\http.js:509:13) at doSend.then.response (E:\js\Easypolicy\node_modules\selenium-webdriver\lib\http.js:441:30) at process._tickCallback (internal/process/next_tick.js:68:7) From: Task: sendKeys at thenableWebDriverProxy.schedule (E:\js\Easypolicy\node_modules\selenium-webdriver\lib\webdriver.js:807:17) at actions.map.action (E:\js\Easypolicy\node_modules\selenium-webdriver\lib\actions.js:124:23) at Array.map ()
at E:\js\Easypolicy\nodemodules\selenium-webdriver\lib\actions.js:123:29
at TaskQueue.execute (E:\js\Easypolicy\nodemodules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext (E:\js\Easypolicy\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (E:\js\Easypolicy\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at E:\js\Easypolicy\node_modules\selenium-webdriver\lib\promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: ActionSequence.perform
at ActionSequence.perform (E:\js\Easypolicy\node_modules\selenium-webdriver\lib\actions.js:122:33)
at UserContext. (E:\js\Easypolicy\Hdfc.js:23:58)
at E:\js\Easypolicy\node_modules\jasminewd2\index.js:112:25
at new ManagedPromise (E:\js\Easypolicy\node_modules\selenium-webdriver\lib\promise.js:1077:7)
at ControlFlow.promise (E:\js\Easypolicy\node_modules\selenium-webdriver\lib\promise.js:2505:12)
at schedulerExecute (E:\js\Easypolicy\nodemodules\jasminewd2\index.js:95:18)
at TaskQueue.execute (E:\js\Easypolicy\nodemodules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext (E:\js\Easypolicy\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (E:\js\Easypolicy\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at E:\js\Easypolicy\node_modules\selenium-webdriver\lib\promise.js:668:7
From: Task: Run it("HDFC Proposal Journey") in control flow
at UserContext. (E:\js\Easypolicy\node_modules\jasminewd2\index.js:94:19)
From asynchronous test:
Error
at Suite. (E:\js\Easypolicy\Hdfc.js:4:2)
at Object. (E:\js\Easypolicy\Hdfc.js:1:63)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)