Chromedriver: session deleted because of page crash - javascript

I am writing tests for my AngularJS application using protractor and jasmine.
I am testing file upload case using the code below:
const fileElem = element(by.css('input[type="file"]'));
fileElem.sendKeys(absoluteFilePath);
browser.sleep(500);
It works locally with the next packages:
"chromedriver": "2.38.2", "protractor": "5.3.1", Chrome - v.66.0.3359.139
But when I run this tests on GitLab CI, I get an error:
[chrome #01] F ✗ should upload the file
[chrome #01] - Failed: unknown error: session deleted because of
page crash
[chrome #01] from unknown error: cannot determine loading status
[chrome #01] from tab crashed
[chrome #01] (Session info: headless chrome=65.0.3325.181)
[chrome #01] (Driver info: chromedriver=2.38.552522
(437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Linux
4.13.5-coreos-r2 x86_64)
I am using ng-file-upload directive.
Thanks for your help!

i had the same problem while running selenium on my vps. After 5 hours i found that, too much unclosed process try to use the driver. try ti kill them all
pkill -f chrome*

sendKeys enter string char by char, the model will detect change when each char be entered. So if the file path has 10 chars, the model will detect 10 times change. Each time model change will trigger file upload. But the file path of the first 9 times are incorrect and so frequent file uploading lead to browser crash.
const fileElem = element(by.css('input[type="file"]'));
// input file path by javascript in silent to avoid multiple model change
browser.executeScript(
'arguments[0].value=arguments[1];',
fileElem.getWebElement(),
absoluteFilePath
);
// input a blank space at the end of file path
// to let model detect change, then trigger file uploading.
fileElem.sendKeys(" ");

Related

Unable to run test on Chrome in Travis-Ci

I am working on JavaScript and Node.js project and I'm very new to Travis-Ci.
I have configured .travis.yml according to project requirement :
language: node_js
node_js:
- node
os: windows
addons:
chrome: stable
script:
- npm test
But, after adding all the necessary tags still, I'm facing some issues related to the Chrome browser.
After any commit, the 'Travis-Ci' will run the tests and shows the passing results, and then showing the below error:
Smoke Suite :
√ Verify that User is able to Sign in with existing Email Team credentials.
1 passing (11ms)
The command "npm test" exited with 7.
>
> C:\Users\travis\build\username\tavis-demo\node_modules\mocha\lib\runner.js:962
> throw err;
> ^ WebDriverError: unknown error: cannot find Chrome binary (Driver info: chromedriver=90.0.4430.24
> (4c6d850f087da467d926e8eddb76550aed655991-refs/branch-heads/4430#{#429}),platform=Windows
> NT 10.0.17763 x86_64)
If anyone has a solution for this please respond.
Thanks!

Failed: javascript error: circular reference [duplicate]

After update of chromedriver to version 2.46 my tasts fail to initialize.
I got message like this:
Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 44269
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Failed to invoke configuration method com.personal.CustomTest.initTests not created: Chrome version must be between 71 and 75
(Driver info: chromedriver=2.46.628402,platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.58 seconds
Build info: version: '2.53.1'
It is clearly saying that my browser version is not valid. But I am using Chrome 72.0.3626.119 so it is between 71 and 75.
Selenium version is 2.53.1.
And I am running test through console command with the help of testNG.
Any idea? Every ideas that I found was about changing selenium version but I cant do it.
For me to resolve this problem :
On Windows
cd C:\Users\[myname]\AppData\Roaming\npm\node_modules\protractor
npm i webdriver-manager#latest
webdriver-manager update
webdriver-manager start &
On Cent-OS (I used Cent-OS 7.4.* and it worked fine.)
cd /usr/lib/node_modules/protractor/
sudo npm i webdriver-manager#latest
sudo webdriver-manager update
sudo webdriver-manager start &
I hope this helps you in any way.
This error message...
Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 44269
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Failed to invoke configuration method com.personal.CustomTest.initTests not created: Chrome version must be between 71 and 75
...implies that the ChromeDriver v2.46 is not compatible with the Chrome Browser version which is being accessed by your program/webdriver.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.46
Release Notes of chromedriver=2.46 clearly mentions the following :
Supports Chrome v71-73
Though you mentioned you are using Chrome 72.0.3626.119 possibly there are multiple instances of Chrome Browser installed within your system and your program by default is accessing the Chrome Browser whose version is not between v71.x and v75.x
You are using chrome=67.0
Release Notes of ChromeDriver v2.38 clearly mentions the following :
Supports Chrome v65-67
Solution
Keep JDK upgraded to recent levels JDK 8u201.
Uninstall all the instances of Chrome Browser (you can opt to use Revo Uninstaller).
Upgrade ChromeDriver to current ChromeDriver v2.46 level.
Keep Chrome version between Chrome v71-73 levels. (as per ChromeDriver v2.46 release notes)
For me, I had to update my chrome driver in my project to match the version of Chrome on my local machine.
yarn add chromedriver#76.0.0 -D
https://www.npmjs.com/package/chromedriver
In my case I was getting the same error after my chrome was updated to version 76. Which was happening when chimp tries to use chromedriver to execute the selenium test.
DevTools listening on ws://127.0.0.1:49220/devtools/browser/e88586cb-ed67-44fc-a742-43b767e2b8f9
[chimp][helper] setupBrowserAndDDP had error
{ Error: session not created: Chrome version must be between 71 and 75
at Object.wait (C:\ACPMS\ELS_AT\node_modules\fibers\future.js:449:15)
at Object.<anonymous> (C:\ACPMS\ELS_AT\node_modules\wdio-sync\build\index.js:344:27)
at Object.<anonymous> (C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\session-manager.js:145:21)
at initBrowser (C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\chimp-helper.js:189:43)
at Object.setupBrowserAndDDP (C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\chimp-helper.js:264:7)
at Context.<anonymous> (C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\mocha\mocha-helper.js:13:15)
at C:\ACPMS\ELS_AT\node_modules\chimp\dist\lib\utils\fiberize.js:29:22
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17134 x86_64)
at new RuntimeError (C:\ACPMS\ELS_AT\node_modules\webdriverio\build\lib\utils\ErrorHandler.js:143:12)
at Request._callback (C:\ACPMS\ELS_AT\node_modules\webdriverio\build\lib\utils\RequestHandler.js:318:39)
at Request.self.callback (C:\ACPMS\ELS_AT\node_modules\request\request.js:185:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (C:\ACPMS\ELS_AT\node_modules\request\request.js:1161:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous>
For me it didn't work when I updated the chrome driver by npm (both globally and locally) and then I followed these steps to resolve the issue, which might give some idea on where to check in this kind a issue:
Because exception was thrown in node_modules\chimp\dist\lib\utils\fiberize.js i navigated to that file and found one level above this file node_modules\chimp\dist\lib\chromedriver.js which has the code to start chromedriver.
I added a console.log to chromedriverPath which can be seen below and re-executed the tests to get the chromedriver path in console logs.
Chromedriver.prototype.start = function(callback) {
var self = this;
var port = self.options.port;
if (this.child) {
callback();
return;
}
var chromedriverPath = chromedriver.path;
//this was added my me the see that chrome drive path
console.log("[chimp] " + chromedriverPath);
if (fs.existsSync(chromedriverPath)) {
this.child = processHelper.start(
{
bin: chromedriverPath,
prefix: "chromedriver",
args: ["--port=" + port, "--url-base=wd/hub"],
waitForMessage: /Starting ChromeDriver/,
errorMessage: /Error/
},
callback
);
} else {
callback("[chimp][chromedriver] Chromedriver executable not found.");
}
};
When i got the path of the chromedriver which is used to execute the tests, i just navigated to that folder and replaced chromedriver executable with the most recent version.
I hope this helps.
Try this: Download the compatible ChromeDriver.exe file for the updated version of Chrome browser and replace it. It works for me.

Jenkins + Selenium random unknown server-side error during Karma+Mocha tests

I have CI system. It consists of
Jenkins Master server (version 2.60.2) running on Ubuntu 16.04
Jenkins slaves Swarm Slave (version 3.4.1) running on Ubuntu 16.04
Selenium hub (version 3.4.0) running on Ubuntu 16.04
4 Selenium nodes for Safari Browser (version 3.4.0) Running on Mac OS Siera 10.12.5 .
With Safari 10.
Im testing Java Script project that uses Mocha+Karma to run tests.
Most of the time everything is working as it should.
But sometimes i have error like this one.
{"message":"[get(\"http://my-jenkins-slave-hostname:9876/?id=39481\")] Error response status: 13, UnknownError - An unknown server-side error occurred while processing the command. Selenium error: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 8 path $","status":13,"cause":{"value":{"stacktrace":"com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient...
It looks like some nodes of selenium sometimes fail randomly.
All nodes are exact replicas of same image (Im using Mac Stadium to manage Mac OS nodes)
Ive tried to configure Karma to give more details in logs, ive tried to increase timeouts, but no luck. Error message stays the same.
How can i troubleshoot such problem?
Any ideas?

How can I use local storage with Protractor and CucumberJS? [duplicate]

describe('The feature', function() {
beforeEach(function () {
browser.executeScript('localStorage.setItem("key","value");');
});
it('should do this', function() {
});
});
but i get this error when the test is run against selenium with chromedriver 2.10 and chrome 37
Executing: [execute script: window.localStorage.setItem("key","value");, []])
15:31:29.747 WARN - Exception thrown
org.openqa.selenium.WebDriverException: <unknown>: Failed to read the 'localStorage'
property from 'Window': Storage is disabled inside 'data:' URLs.
(Session info: chrome=37.0.2062.120)
(Driver info: chromedriver=2.10.267518,platform=Linux 3.11.0-26-generic x86_64) (WARNING:
The server did not provide any stacktrace information)
Any idea where the problem cam from ?
According to one of the answers at Remove an item from localStorage in a protractor test, this happens when you try to access localStorage without hitting the browser (say, browser.get) first when you are using the Chrome driver. The solution seems to be to hit the browser first (maybe your root page) to get a page loaded in Chrome so that you can manipulate the localStorage. That at least is what I have been doing for our project. Hope this helps!

Running Karma tests with google maps module dependency

So i included this module into my Angular app https://github.com/angular-ui/angular-google-maps
Now the question is: How to I run Karma tests that integrate it?
Running "karma:unit" (karma) task
INFO [karma]: Karma v0.10.6 server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
WARN [watcher]: Pattern "/Users/Work/status/test/mock/**/*.js" does not match any file.
INFO [Chrome 31.0.1650 (Mac OS X 10.8.4)]: Connected on socket iLYLgPcHaw8HVJjNNafq
Chrome 31.0.1650 (Mac OS X 10.8.4) ERROR
Uncaught ReferenceError: google is not defined
at /Users/Work/status/app/scripts/angular-google-maps.min.js:6
Chrome 31.0.1650 (Mac OS X 10.8.4): Executed 0 of 0 ERROR (0.509 secs / 0 secs)
Warning: Task "karma:unit" failed. Used --force, continuing.
Done, but with warnings.
So it is the global google object that is missing
I see a couple of solutions but do not know how to implement them:
-Inject the google script everytime we run tests (although inefficient). Question is, how and where do I inject it?
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=en"></script>
-i read a suggestion somewhere that we could mock the google API
This has been asked a few times already in the issues list on the project. Here is one of the q/a.
https://github.com/angular-ui/angular-google-maps/issues/270

Categories