session not created exception for chrome in Protractor

前端 未结 6 1894
轮回少年
轮回少年 2020-12-11 03:29

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

My conf.ts

import {Config} from \'protractor\'

export let config: Config = {
    f         


        
相关标签:
6条回答
  • 2020-12-11 03:49

    I just needed to:

    npm update -g protractor
    webdriver-manager update
    

    And it worked again.

    0 讨论(0)
  • 2020-12-11 03:52

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

    0 讨论(0)
  • 2020-12-11 03:57

    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';
    0 讨论(0)
  • 2020-12-11 04:00
    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.

    0 讨论(0)
  • 2020-12-11 04:05

    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.

    0 讨论(0)
  • 2020-12-11 04:06

    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.

    0 讨论(0)
提交回复
热议问题