Protractor issue with chromedriver versions like 7

2020-02-13 05:12发布

问题:

Protractor issue while running the conf.js file for new chromedriver versions like 76.0.3809.68

I am trying to run the protractor tests on latest chrome version which got updated today 76.0.3809.100 but they keep failing and giving error. The versions that i have are protractor version: 5.4.2, webdriver-version: 12.1.6, selenium standalone version available: 3.141.59 chromedriver versions available: 2.46 [last], 76.0.3809.12 geckodriver version available: v0.24.0 [last]

I have tried updating the webdriver manager using webdriver-manager update to update the chrome driver, have also tried to reinstall the webdriver-manager and insatll a specific version of webdriver but nothing seems to be working. I also tried to install a lower version of chrome i.e 75 but everytime i try it installs the latest version instead. The tests were running fine before just after the update they stopped working. Any help / suggestion regarding this issue would be really helpful.

This is the error being thrown:

E/launcher - session not created: Chrome version must be between 71 and 75
  (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17763 x86_64)
[15:08:03] E/launcher - SessionNotCreatedError: session not created: Chrome version must be between 71
and 75
  (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17763 x86_64)
    at Object.checkLegacyResponse (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:546:15)
    at parseHttpResponse (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
    at doSend.then.response (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:441:30)
    at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: WebDriver.createSession()
    at Function.createSession (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
    at Function.createSession (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\chrome.js:761:15)
    at Direct.getNewDriver (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\built\driverProviders\direct.js:77:33)
    at Runner.createBrowser (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\built\runner.js:195:43)
    at q.then.then (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\built\runner.js:339:29)
    at _fulfilled (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
    at C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30
    at Promise.promise.promiseDispatch (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
    at C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:556:49
    at runSingle (C:\Users\gmangat\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:137:13)
[15:08:03] E/launcher - Process exited with error code 199

This is my conf.js file exports.config = {

directConnect: true,
  multiCapabilities: [{
    browserName: 'chrome',
    acceptInsecureCerts: true,
    'specs': [
      //e2e Specs
      './src/e2e/shared/specs/LoginTest.e2e.spec.js',
      './src/api/unified-message-api/specs/createUMTask.js',
     ],
    chromeOptions: {
      args: ['--disable-infobars', '--disable-browser-side-navigation'],
      prefs: {
        'profile.managed_default_content_settings.notifications': 1
      }
    },
  }],
  framework: 'jasmine2',
  SELENIUM_PROMISE_MANAGER: true,
  onPrepare: function () {
    browser.ignoreSynchronization = true;
    browser.driver.manage().timeouts().implicitlyWait(5000);
    browser.driver.manage().window().setSize(1280, 1024);

    //npm install jasmine-spec-reporter --save-dev
    var specReporter = require('jasmine-spec-reporter').SpecReporter;
    jasmine.getEnv().addReporter(new specReporter({
      displayFailuresSummary: true,
      displayFailuredSpec: true,
      displaySuiteNumber: true,
      displaySpecDuration: true
    }));

    var AllureReporter = require('jasmine-allure-reporter');
    jasmine.getEnv().addReporter(new AllureReporter({
      resultsDir: 'allure-results'
    }));
    jasmine.getEnv().afterEach(function (done) {
      browser.takeScreenshot().then(function (png) {
        allure.createAttachment('Screenshot', function () {
          return new Buffer(png, 'base64')
        }, 'image/png')();
        done();
      })
    });
  },

  jasmineNodeOpts: {
    defaultTimeInterval: 6000000
  }

};

/* Version Used:
Node: 10.15.3
Protractor : 5.4.2
npm i protractor@5.4.2

*/

回答1:

The solution that worked for me was navigating to ./node_modules/protractor and running npm i webdriver-manager@latest.

Then go back to the app root and run webdriver-manager update and this time it should download the v76 driver.



回答2:

You need to install compatible chromedriver version which is 76.0.0. chromedriver versioning convention is now changed to track the chrome version.



回答3:

I was also facing same issue, here is a workaround which I tried and it helped me:

  1. I did a fresh install of Node, npm, Protractor - All latest versions
  2. I did npm install -g protractor and webdriver-manager update which downloaded chromedriver_76.0.3809.12.zip and geckodriver_v0.24.0
  3. Also I am using few npm modules in my test which I install locally by npm install command under ~\<Project Folder>\Test\npm_modules
  4. I replaced content of selenium folder from C:\Users\<username>\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\selenium\ to ~\<Project Folder>\Test\npm_modules\Protractor\node_modules\webdriver-manager\selenium\ and this fixed the above mentioned error.