Lost UI Shared Context Error - Running protractor tests in headless chrome - angularjs

I am attempting to run protractor tests locally using chrome but in headless mode, I have seen the docs and added the appropriate options to my config file:
capabilities: {
browserName: 'chrome',
shardTestFiles: true,
chromeOptions: {
args: [ '--headless', '--disable-gpu', '--window-size=800,600' ]
}
}
Upon running, I encounter the following error:
[1009/122000.081:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
I tried removing the --disable-gpu flag as I read this may not be needed in future version of Chrome. I currently have latest Chrome installed (69.0.3497.100) and am using windows 7.
What do I need to do in order to get the tests running in headless mode? My intention is to check I can run in headless mode fine locally and then I want to get it running also in Chrome headless mode on a linux Jenkins node, where we are currently using XVFB but its proving to be too flaky with timeouts in tests for example.
Thanks
EDIT
With regards to others marking this as a duplicate - I should have said that my tests fail to run when I attempt to use the headless option, without the chrome options set, Chrome launches as expected and the test run and pass successfully.
My tests fail with no such element found type errors and if I view the screenshots taken on the failures, I just see a white square inside a black background (probably as per the --window-size option I was setting)

As you mentioned you are using Chrome headless mode on a linux Jenkins node you need consider a few factors as follows:
--disable-gpu
When Headless Chrome was first released as GA (General Availability) by Google Team the article Getting Started with Headless Chrome mentioned that :
--disable-gpu \ # Temporarily needed if running on Windows.
A note was added as :
Right now, you'll also want to include the --disable-gpu flag if you're running on Windows.
As per the discussion Headless: make --disable-gpu flag unnecessary it was clear that :
The --disable-gpu flag is no longer necessary on Linux or Mac OSX. It will also become unnecessary on Windows as soon as the bug SwiftShader fails an assert on Windows in headless mode is fixed.
You can find a detailed discussion on What happened under the hood in the discussion ChromeDriver showing Lost UI Shared Context
So as a first step you need to remove the argument: '--disable-gpu'
flaky tests
You seem to be executing your tests with the argument --window-size=800,600 which implies a reduced Viewport.
In order to utilize the maximum possible Viewport you must initialize the Chrome Browser in maximized mode through the argument: 'start-maximized'
angular
From Angular perspective, you can avoid timeouts by using the proper expected_conditions. You can find a detailed discussion about different expected_conditions in WebDriverWait not working as expected
--headless
Finally, I am not sure what exactly you meant as in ...my tests fail to run when I attempt to use the headless option, without the chrome options set.... Perhaps the argument '--headless' can be invoked only through chromeOptions and no other alternative.

I have the same error while running [1010/161441.019:ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
but my test runs perfect.I have you referred this https://gist.github.com/cvuorinen/543c6f72f8ec917ebfd596802d387aa3
I hope this below may help you
https://cvuorinen.net/2017/05/running-angular-tests-in-headless-chrome/
https://developers.google.com/web/updates/2017/04/headless-chrome

Related

Value attribute not present on input element | AngularJS, Chrome 91, Protractor

After updating chrome driver to ChromeDriver 91.0.4472.19
The value attribute have dissapeared from the input elements. Protractor cannot access the value attribute.
let x = await xDiv.getEl("#xInput").getAttribute('value');
// x = null
Using the Chrome Dev Tools, I am also not able to see the value attribute of any input element in the markup.
Using AngularJS 1.5.8 and Protractor/Selenium 3.141.59
The problem you described is actually a bug in chromedriver https://bugs.chromium.org/p/chromium/issues/detail?id=1205107. It happened because of the change in chrome browser related to W3C compliance
As you can see, the plan is to fix the bug, however it is still in progress.
Meanwhile, I recommend you 2 workarounds:
you can use chromedriver version 90. The latest version available is here https://chromedriver.storage.googleapis.com/LATEST_RELEASE_90.0.4430
I know that under normal circumstances this would throw incompatibility error, but somehow chromedriver 90 works with chrome 91.
You can downgrade chromedriver by running this command
webdriver-manager update --gecko=false --versions.chrome 90.0.4430.24
Note sometimes you have global, project local and Protractor specific installations of webdriver-manager. The command I gave will install chromedriver globally. In order to install locally you need to find the path to your webdriver-manager and run command like this
node ./node_modules/protractor/node_modules/webdriver-manager update --gecko=false --versions.chrome 90.0.4430.24
And some of you may need to run command in sudo mode. Keep it in mind
Instead of elem.getAttribute('value') try to go with browser.executeScript('return arguments[0].value', elem); multiple users claimed it works for them
Additionally, read this answer https://stackoverflow.com/a/67888592/9150146 that proposes more hacky solutions

ExtJS7: How to test `onAppUpdate` in dev or testing environment

ExtJS v7.1 based application has onAppUpdate function and some other methods like onLaunch mentioned in documantation here for classic application. However in development and in testing environment these never gets fired. Is it as intended, if yes then how we can test onAppUpdate in dev or testing build. If no, then what could have gone wrong here.
You can achieve this by enabling Local Storage Cache for a specific build in your app.json file.
Example for the testing build:
/**
* Settings specific to testing builds.
*/
"testing": {
"cache": {
"enable": true
}
},
Every build on the testing environment will now call the onAppUpdate() function.
Note that you'll never see an onAppUpdate event triggered if you are using a dev build; it needs to be packaged (with caching enabled, as #ground_call points out). The point of onAppUpdate is that you've got a cached version which is older than what's now available - no cache, no onAppupdate
If you're willing to trust the infrastructure, and just test what your app does, you can always trigger the onAppUpdate event programmatically, either in a test script or from the JavaScript console.

How to change "Block third-party cookies" in Chromium through ChromeDriver?

I am using ChromeDriver 80.0.3987.106 with Chromium 80.0.3987.122 and I am running some Javascript tests inside Chromium and fetch results using the driver.
I get this error after I updated both Chromium and the driver (from version 67):
Failed to read the 'sessionStorage' property from 'Window': Access is denied for this document.
After some googling around, I found the issue reported here. Basically, the problem is this setting:
However I am not finding a way to change its value to false using the driver's API.
Attempts
I checked:
Chromium flags
Chromium switches
Chromium prefs
But that option does not seem to be there.
I also faced this problem.
You can use custom chrome profile setting. I used my own chrome profile setting and succeeded to use selenium with setting the option false.
https://chromedriver.chromium.org/capabilities#TOC-Use-custom-profile-also-called-user-data-directory-

Running e2e tests using Protractor multiCapabilities config but limit max Webdriver instances

Context
I am trying the brand new Protractor 0.19.0 with the multiCapabilities config option. It is actually working as described in the docs :
It makes running tests on multiple browsers easier (no need for grunt, nor script, only 1 config file).
It makes tests running in parallel
The second point is problematic for me. One of my app doesn't handle multiple connection to the data, implying that the tests fail.
My question is:
Is it possible to limit the maximum number of instances of Webdriver in order to disable parallel testing for this app?
What I have tried
I've found in Selenium Webdriverjs Grid2 wiki that there's a maxSession parameter that would perfectly fit to my case! But I tried to add it in my Protractor config, without success.
maxSession is also in the Desired Capabilities. Anyone knows if it's working yet?
Here is the link to the multiCapabilities PR topic, I left a comment there.
If you need more info, feel free to ask :)
Thanks in advance!!
EDIT: Dedicated GitHub issue
EDIT2: I recently tried to add seleniumArgs: ['-maxSession=1'] to my Protractor config, unfortunaltely this doesn't work too...
Implemented in this commit and released in 0.24.0 (See Protractor changelog).
You need to add a maxSessions option into your protractor config file with a value >=1 (otherwise it is considered as unlimited).
protractor.config.js example:
exports.config = {
seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
specs: [
'../e2e/**/*.js'
],
multiCapabilities: [
{'browserName': 'chrome'},
{'browserName': 'firefox'},
{'browserName': 'phantomjs'}
],
maxSessions: 1,
baseUrl: 'http://localhost:8000'
};
Tested and working as expected for my case.
I think you can set this by launching selenium nodes in command line and by giving:
MaxInstances This says....how many instances of same version of browser can run over the Remote System.
or
MaxSession This says....how many browsers (Any Browser and any version) can run in parallel at a time in the remote system. So this overrides the Max Instances settings and can restrict the number of browser instances that can run in parallel.
from this answer
So you will run your node as such :
java -jar selenium-server-standalone-2.14.0.jar -role node -hub http://******:4444/grid/register -maxSession 5

Qooxdoo - Theme to use is not available

I have an qx v2.0.1 app working off the local file system and it runs fine in Firefox v14, but in Chrome v18 it gives me this error:
Uncaught Error: The theme to use is not available: edd.theme.Theme
qx.Class.define.members.initializeMeta.js:108
qx.Class.define.members.mainAbstractGui.js:82
qx.Class.define.members.baseObject.js:141
qx.Class.define.members.mainApplication.js:38
qx.Class.define.statics.readyBaseInit.js:77
qx.Class.define.members.dispatchEventDirect.js:134
wrappedFunctionInterface.js:451
qx.Class.define.members.dispatchEventManager.js:873
qx.Class.define.statics.fireEventRegistration.js:310
qx.Class.define.members.__fireReadyApplication.js:188
qx.Class.define.statics.onScriptLoadedApplication.js:106
qx.$$loader.signalStartupedd.js:159
qx.$$loader.initUrisedd.js:195
I thought I've come across this before and a ./generate.py distclean fixed it, but not this time. Someone else had a similar bug that was fixed:
http://bugzilla.qooxdoo.org/show_bug.cgi?id=1463
Any ideas?
This question is too tricky, and probably involves things like looking at verbose generator output and your job configs, so it is not really suitable for a Q&A site. I suggest you open up a bug for it at the qooxdoo project.
Interestingly enough, after a computer reboot it started working in chrome again. So the chrome clear browser cache/history everything since the beginning of time must not catch everything. So now it's working again...odd.

Resources