Shabar
Shabar

Reputation: 2823

session not created exception for chrome in Protractor

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

Upvotes: 10

Views: 34481

Answers (7)

Vikram
Vikram

Reputation: 1

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",

Upvotes: 0

Raj Kumar
Raj Kumar

Reputation: 798

  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.

Upvotes: 1

Johnny
Johnny

Reputation: 15423

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';

Upvotes: 0

Marc Stober
Marc Stober

Reputation: 10517

I just needed to:

npm update -g protractor
webdriver-manager update

And it worked again.

Upvotes: 4

Sevfuria
Sevfuria

Reputation: 56

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 :)

Upvotes: 1

tehbeardedone
tehbeardedone

Reputation: 2858

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.

Upvotes: 7

Sudharsan Selvaraj
Sudharsan Selvaraj

Reputation: 4832

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.

Upvotes: 13

Related Questions