How to downgrade Chrome WebDriver in angular Protractor

Mhyland  picture Mhyland · Jun 11, 2019 · Viewed 9.9k times · Source

I am trying to run ng e2e on Angular 7 with chrome as the browser. I ran the commands npm install -g protractor and webdriver-manager update. It ends up downloading and running chromedriver=76.0.3809.12 but it is not possible for me to update chrome itself on my machine. I am on chrome 74.

I have tried webdriver-manger update, webdriver-manager update --versions.chrome 2.46, and webdriver-manager update --versions.chrome 74.0.3729.6 but even if I go and delete the chrome 76 files from node_modules\protractor\node_modules\webdriver-manager\selenium\ but they always reinstall everytime I run ng e2e

protractor.conf.js

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './src/**/*.e2e-spec.ts'
  ],
  capabilities: {
    'browserName': 'chrome'
  },
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {}
  },
  onPrepare() {
    require('ts-node').register({
      project: require('path').join(__dirname, './tsconfig.e2e.json')
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  }
};

tsconfig.e2e.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "commonjs",
    "target": "es5",
    "types": [
      "jasmine",
      "jasminewd2",
      "node"
    ]
  }
}

when I attempt to run ng e2e it throws this error:

E/launcher - session not created: This version of ChromeDriver only supports Chrome version 76
  (Driver info: chromedriver=76.0.3809.12 (220b19a666554bdcac56dff9ffd44c300842c933-refs/branch-heads/3809@{#83}),platform=Windows NT 10.0.16299 x86_64)
E/launcher - Process exited with error code 199
An unexpected error occurred: undefined

UPDATE: when I ran webdriver-manager clean and node node_modules/protractor/bin/webdriver-manager update --standalone --versions.standalone=3.8.0 it still downloaded chrome 76 here is the output of the second command and ng e2e after the clean

node node_modules/protractor/bin/webdriver-manager update --standalone --

versions.standalone=3.8.0
[06:59:13] I/config_source - curl -oM:.\node_modules\protractor\node_modules\webdriver-manager\selenium\standalone-response.xml https://selenium-release.storage.googleapis.com/
[06:59:13] I/config_source - curl -oM:.\node_modules\protractor\node_modules\webdriver-manager\selenium\chrome-response.xml https://chromedriver.storage.googleapis.com/
[06:59:13] I/config_source - curl -oM:.\node_modules\protractor\node_modules\webdriver-manager\selenium\gecko-response.json https://api.github.com/repos/mozilla/geckodriver/releases
[06:59:14] I/downloader - curl -oM:.\node_modules\protractor\node_modules\webdriver-manager\selenium/selenium-server-standalone-3.8.0.jar https://selenium-release.storage.googleapis.com/3.8/selenium-server-standalone-3.8.0.jar
[06:59:14] I/update - chromedriver: file exists M:.\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_76.0.3809.12.zip
[06:59:14] I/update - chromedriver: unzipping chromedriver_76.0.3809.12.zip
[06:59:14] I/update - chromedriver: chromedriver_76.0.3809.12.exe up to date
[06:59:14] I/update - geckodriver: file exists M:.\node_modules\protractor\node_modules\webdriver-manager\selenium\geckodriver-v0.24.0.zip
[06:59:14] I/update - geckodriver: unzipping geckodriver-v0.24.0.zip
[06:59:15] I/update - geckodriver: geckodriver-v0.24.0.exe up to date

ng e2e

i 「wdm」: Compiled successfully.
[07:00:51] I/update - chromedriver: file exists M:.\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_76.0.3809.12.zip
[07:00:51] I/update - chromedriver: unzipping chromedriver_76.0.3809.12.zip
[07:00:52] I/update - chromedriver: chromedriver_76.0.3809.12.exe up to date
[07:00:54] I/launcher - Running 1 instances of WebDriver
[07:00:54] I/direct - Using ChromeDriver directly...
[9224:10012:0612/070058.684:ERROR:configuration_policy_handler_list.cc(90)] Unknown policy: EnableCommonNameFallbackForLocalAnchors
[9224:10012:0612/070058.869:ERROR:configuration_policy_handler_list.cc(90)] Unknown policy: EnableCommonNameFallbackForLocalAnchors

DevTools listening on ws://127.0.0.1:5007/devtools/browser/376b234b-f47d-4841-afdc-77719714db23
[07:01:05] E/launcher - session not created: This version of ChromeDriver only supports Chrome version 76
  (Driver info: chromedriver=76.0.3809.12 (220b19a666554bdcac56dff9ffd44c300842c933-refs/branch-heads/3809@{#83}),platform=Windows NT 10.0.16299 x86_64)
[07:01:05] E/launcher - SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 76
  (Driver info: chromedriver=76.0.3809.12 (220b19a666554bdcac56dff9ffd44c300842c933-refs/branch-heads/3809@{#83}),platform=Windows NT 10.0.16299 x86_64)

package.json

  "private": true,
  "dependencies": {
    "@angular/animations": "^7.2.14",
    "@angular/cdk": "^7.3.7",
    "@angular/common": "^7.2.14",
    "@angular/compiler": "^7.2.14",
    "@angular/core": "^7.2.14",
    "@angular/forms": "^7.2.14",
    "@angular/http": "^7.2.14",
    "@angular/material": "^7.3.7",
    "@angular/platform-browser": "^7.2.14",
    "@angular/platform-browser-dynamic": "^7.2.14",
    "@angular/platform-server": "^7.2.14",
    "@angular/router": "^7.2.14",
    "core-js": "^2.5.7",
    "rxjs": "^6.5.2",
    "rxjs-compat": "^6.5.1",
    "zone.js": "^0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.13.8",
    "@angular/cli": "^7.3.8",
    "@angular/compiler-cli": "^7.2.14",
    "@angular/language-service": "^7.2.14",
    "@types/jasmine": "^3.3.12",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^11.13.8",
    "codelyzer": "^5.0.1",
    "jasmine-core": "^3.4.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^4.1.0",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cli": "^2.0.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "^5.4.2",
    "rxjs-tslint": "^0.1.7",
    "ts-node": "~5.0.1",
    "tslint": "^5.16.0",
    "typescript": "<3.3.0",
    "webpack": "^4.30.0"
  }

Answer

michelepatrassi picture michelepatrassi · Oct 31, 2019

For who runs into this and would like to use chrome 77, here are the steps:

  • npm i protractor@^5.4.2
  • node node_modules/.bin/webdriver-manager update --versions.chrome=77.0.3865.75
  • make sure that the specified version match in protractor.conf.js under the chromeDriver key.

Here's my protractor config:

exports.config = {
  allScriptsTimeout: 11000,
  specs: ['./src/**/*.e2e-spec.ts'],
  capabilities: {
    browserName: 'chrome',
  },
  chromeDriver: '../node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_77.0.3865.75',
  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function() {},
  },
  onPrepare() {
    require('ts-node').register({
      project: require('path').join(__dirname, './tsconfig.json'),
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
  },
};

I also added the following script in package.json:

 "postinstall": "node_modules/.bin/webdriver-manager update --versions.chrome=77.0.3865.75"

to make sure to have the correct version after each installation.