session not created exception for chrome in Protractor
Asked Answered
D

7

10

I get below error when try to run Protractor test against chrome.

My conf.ts

import {Config} from 'protractor'

export let config: Config = {
    framework: 'jasmine',
    // capabilities: { browserName: 'chrome'},
    multiCapabilities: [
        // {browserName: 'firefox'},
        {
            browserName: 'chrome',
            chromeOptions: {
                args: ['--start-maximized']
            },

        }],

    seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
    seleniumPort: null,
    seleniumArgs: [],
    specs: [
        './Protractor/Login/*.spec.js',

Error:

Protractor conf.js
[17:19:07] I/hosted - Using the selenium server at http://127.0.0.1:4444/wd/hub
[17:19:07] I/launcher - Running 1 instances of WebDriver
[17:19:09] E/launcher - session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"8800.1","isDefault":true},"id":1,"name":"","origin":"://"}
  (Session info: chrome=54.0.2840.59)
  (Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.07 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'MAL000009416062', ip: '192.168.1.4', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_73'
Driver info: org.openqa.selenium.chrome.ChromeDriver
[17:19:09] E/launcher - SessionNotCreatedError: session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"8800.1","isDefault":true},"id":1,"name":"","origin":"://"}
  (Session info: chrome=54.0.2840.59)
  (Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.07 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'MAL000009416062', ip: '192.168.1.4', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_73'
Driver info: org.openqa.selenium.chrome.ChromeDriver
    at WebDriverError (C:\Users\392811\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:5)
    at SessionNotCreatedError (C:\Users\392811\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:308:5)

conf.ts

multiCapabilities: [

        {
            browserName: 'chrome',
            chromeOptions: {
                args: ['--start-maximized']
            },

        }],

Most of the discussion on the web is around version. I am currently using up-to-date versions

Any clue please?

Cheers

Diminution answered 18/10, 2016 at 6:24 Comment(2)
manually download chrome driver version 2.24 and replace it with existing chromdriver.exe file.Waw
@SudharsanSelvaraj I have chromedriver_2.24.exe under this path node_modules\protractor\node_modules\webdriver-manager\seleniumDiminution
W
13

You can change the version of chromedriver downloaded by webdriver-manager by altering Protractor's config.json file...

  1. Edit Protractor's config file: node_modules/protractor/config.json
  2. Change the chrome driver version to whatever you need. eg. "chromedriver": "2.24".
  3. Run webdriver-manager update.

from the error you posted, protractor is not using the latest chrome driver version.In stack trace it is displaying chrome driver version as 2.21.

Waw answered 18/10, 2016 at 6:59 Comment(6)
I am using multiCapabilities: and updated the question with conf.ts section. Still doesn't update with webdriver-manager update command.Diminution
edit the conf.json file present in ` node_modules/protractor/config.json. not your project's conf.js`Waw
I added that to tsconfig.json in the mentioned location. Then ` webdriver-manager update ` results produced below. I/update - chromedriver: file exists C:\Users\392811\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.22win32.zip [20:29:17] I/update - chromedriver: unzipping chromedriver_2.22win32.zip [20:29:17] I/update - chromedriver: v2.22 up to dateDiminution
I realized that I have updated webdriver-manager at the global location. That's why I am getting wrong version there. After updated the correct place it was good.Diminution
upgrading chromedriver worked for webdriverio tests also. I was getting the same error.Pleading
If it is possible, upgrading to the latest version of protractor can also help. In my case there was no config.json in the protractor folder and updating the tconfig.json in the webdriver had no impactAddendum
A
7

I don't have enough rep yet to leave a comment under Sudharsan's answer but the location of the config file he is telling you to modify is actually at

node_modules/protractor/node_modules/webdriver-manager/config.json

It's not the protractor tsconfig but the webdriver-manager config.json that you want to modify.

That being said, I've run into this problem before and taken a different approach to solving it. The solution that Sudharsan provided would work if you only needed to install it once. We have our builds running in TFS which cleans out the build agents working directory and pulls in a fresh repo on each build. Changing the webdriver config would not work in this situation because we npm install all the things before each build. In this case it would always revert back to the older version of chromedriver.

What I did instead was added chromedriver to my devDependencies in the package.json and then I delete the version of chromedriver that webdriver-manager installs and move the updated version of chromedriver into the correct location with a gulp task. So in the package.json I have this listed under devDependencies:

"chromedriver": "~2.24.1"

and then I have a gulp task that deletes and moves the files like this:

var gulp = require('gulp');
var del = require('del');

var chromeDriverFilesToMove = [
    './node_modules/chromedriver/lib/chromedriver/**'
];

var chromeDriverFilesToDelete = [
    './node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver*.exe',
    './node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver*.zip'
];

gulp.task('delete-chromedriver', function() {
    return del(chromeDriverFilesToDelete);
});

gulp.task('move-chromedriver', function() {
    gulp.src(chromeDriverFilesToMove)
        .pipe(gulp.dest('node_modules/protractor/node_modules/webdriver-manager/selenium/'));
});

gulp.task('chromedriver-update', ['delete-chromedriver', 'move-chromedriver']);

And because protractor will still be looking for the older version of chromedriver that was installed when you ran webdriver-manager update you have to tell it where to look for the chromedriver.exe so add this to your protractor conf.js and it should start working.

chromeDriver: "../node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver.exe",

It's kind of silly that we have to go through all this trouble to get it to work but chromedriver 2.22 doesn't seem to work with Chrome 53+. At least not in my experience.

TL;DR

If you only have to install it once use Sudharsan's solution (given you modify the correct config), it's easier. If you are in my situation and will have to install protractor continuously try my solution. It has worked well for me and I haven't run into this error since.

Antipyrine answered 19/10, 2016 at 2:39 Comment(0)
F
4

I just needed to:

npm update -g protractor
webdriver-manager update

And it worked again.

Frans answered 15/11, 2016 at 15:41 Comment(0)
B
1

Protractor has a new release (4.0.10) that will use the new release of webdriver-manager (10.2.6), which in turn will update to the new Chromedriver when calling webdriver-manager update. All you need to do is update Protractor in your package.json file.

"protractor": "^4.0.9" to "protractor": "^4.0.10"

Hope this helps :)

Bizet answered 27/10, 2016 at 16:34 Comment(1)
This worked for me, I am already on latest protractor and chromedriver version. And was getting this error - E/launcher - session not created: Chrome version must be between 70 and 73. I am using- "protractor": "^5.4.1", and [14:44:36] I/update - chromedriver: unzipping chromedriver_2.46.zip [14:44:39] I/update - geckodriver: unzipping geckodriver-v0.24.0.zip. Above solution worked for me. Thanks !Kosiur
L
1
  1. Just run the following command:
  2. Projectdirectory:/>webdriver-manager update --versions.chrome=ChromeVersion
  3. Replace this with "ChromeVersion" Google Chrome Browser Version.Find chrome version by navigating to "Help>>About Google chrome>>For Example: Version 76.0.3809.100 (Official Build) (64-bit)".

I hope this will work for you.

Lineberry answered 12/8, 2019 at 9:32 Comment(0)
A
0

For me, updating chromedriver and protractor-conf.js fixed the issue.

  1. Download latest chromedriver that suitable to your OS (change the minor version if needed) from here: http://chromedriver.storage.googleapis.com/index.html?path=2.24/
  2. Unzip to /usr/local/bin/chromedriver folder.
  3. In protractor-conf.js (should be in app root) add a line with config.chromeDriver = '/usr/local/bin/chromedriver';
Abiogenesis answered 28/11, 2016 at 15:16 Comment(0)
C
0

There is a package.json file under your webdriver-manager folder of users directory - change its webdriver-version to latest one. It should work

"name": "webdriver-manager", "version": "12.1.8",

Creamy answered 2/6, 2023 at 8:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.