0
votes

I am new in Jenkins. I want run automatically my Protractor tests in Jenkins job. And I have problems with ChromeDriver. This is my protractor.confing.js:

const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],


chromeDriver: 'C:/Users/<username>/AppData/Roaming/npm/node_modules/protractor/selenium/chromedriver.exe',

seleniumServerJar: 'C:/Users/<username>/AppData/Roaming/npm/node_modules/protractor/selenium/selenium-server-standalone-2.40.0.jar',
capabilities: {
  'browserName': 'chrome',
 /* "chromeOptions": {
    binary: "C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\chromedriver\lib\chromedriver"
  },*/
},
  chromeDriver:'..\node_modules\webdriver-manager\selenium',
  /*splitTestsBetweenCapabilities: true,
  multiCapabilities: [
    {
      "browserName": "chrome",
      shardTestFiles: true,
      maxInstances: 4
    }
  ],*/
  chromeDriver: 'C:/Users/<username>/AppData/Roaming/npm/node_modules/protractor/selenium/chromedriver.exe',

seleniumServerJar: 'C:/Users/<username>/AppData/Roaming/npm/node_modules/protractor/selenium/selenium-server-standalone-2.40.0.jar',

  directConnect: true,
  baseUrl: 'http://localhost:4200/',
  framework: 'jasmine',
  jasmineNodeOpts: {
    showColors: true,
    defaultTimeoutInterval: 30000,
    print: function () { }
  },
  suites: {
    full: 'e2e/**/**/*.ts',
    powerMax200: 'e2e/tests/powerMax2000/*.ts',
    powerMax200: 'e2e/tests/powerMax8000/*.ts',
    vmax250f: 'e2e/tests/vmax250f/*.ts',
    vmax950f: 'e2e/tests/vmax950f/*.ts'
  },

  onPrepare() {
    var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');

    require('ts-node').register({
      // project: 'e2e/tsconfig.e2e.json',
    });
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
    jasmine.getEnv().addReporter(new Jasmine2HtmlReporter({
      savePath: './e2e/report',
      screenshotsFolder: 'images'
    }));

  }
};

This is my package.js file:

{
    "name": "ui",
    "version": "0.0.0",
    "license": "MIT",
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build --prod",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e" 
    },
    "private": true,
    "dependencies": {
        "@angular/animations": "5.2.0",
        "@angular/common": "5.2.0",
        "@angular/compiler": "5.2.0",
        "@angular/core": "5.2.0",
        "@angular/forms": "5.2.0",
        "@angular/http": "5.2.11",
        "@angular/platform-browser": "5.2.0",
        "@angular/platform-browser-dynamic": "5.2.0",
        "@angular/router": "5.2.0",
        "bootstrap": "4.1.1",
        "core-js": "2.4.1",
        "jquery": "3.3.1",
        "ngx-bootstrap": "^3.0.1",
        "popper.js": "^1.14.3",
        "protractor-jasmine2-html-reporter": "0.0.7",
        "protractor-jasmine2-reporter": "^1.1.0",
        "protractor-jasmine2-screenshot-reporter": "^0.5.0",
        "selenium-webdriver": "2.52",
        "rxjs": "5.5.6",
        "zone.js": "0.8.19",
        "protractor": "^3.2.2"
    },
    "devDependencies": {
        "@angular/cli": "1.7.3",
        "@angular/compiler-cli": "5.2.0",
        "@angular/language-service": "5.2.0",
        "@types/jasmine": "2.8.3",
        "@types/jasminewd2": "2.0.2",
        "@types/node": "6.0.60",
        "codelyzer": "4.0.1",
        "jasmine-core": "2.8.0",
        "jasmine-spec-reporter": "4.2.1",
        "karma": "2.0.2",
        "karma-chrome-launcher": "2.2.0",
        "karma-coverage-istanbul-reporter": "1.2.1",
        "karma-jasmine": "1.1.0",
        "karma-jasmine-html-reporter": "0.2.2",
        "protractor": "5.3.2",
        "ts-node": "4.1.0",
        "tslint": "5.9.1",
        "typescript": "2.5.3"
    },
    "bin": {
        "protractor": "bin/protractor",
        "webdriver-manager": "bin/webdriver-manager"
    }
}

In my Jenkins job I pull code from BitBucket repository. And I execute Windows batch commands:

  • cd NewGenProject/ui/
  • npm install
  • npm -g install protractor
  • npm install -g @angular/cli
  • npm i jasmine-spec-reporter
  • ng e2e --no-webdriver-update

And i have error in console :

Started by user Admin
Building in workspace C:\Program Files (x86)\Jenkins\workspace\newGen_protractor
 > C:\Program Files\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > C:\Program Files\Git\bin\git.exe config remote.origin.url https://[email protected]/night_riders/desingstudio_new_gen.git # timeout=10
Fetching upstream changes from https://[email protected]/night_riders/desingstudio_new_gen.git
 > C:\Program Files\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials 
 > C:\Program Files\Git\bin\git.exe fetch --tags --progress https://[email protected]/night_riders/desingstudio_new_gen.git +refs/heads/*:refs/remotes/origin/*
Seen branch in repository origin/application.properties
Seen branch in repository origin/develop
Seen branch in repository origin/features/conf_view_changes
Seen branch in repository origin/master
Seen 4 remote branches
 > C:\Program Files\Git\bin\git.exe show-ref --tags -d # timeout=10
Checking out Revision 385630d58f9f32f9032fe522b59dc3b02bffb601 (origin/application.properties)
 > C:\Program Files\Git\bin\git.exe config core.sparsecheckout # timeout=10
 > C:\Program Files\Git\bin\git.exe checkout -f 385630d58f9f32f9032fe522b59dc3b02bffb601
Commit message: "web driver"
 > C:\Program Files\Git\bin\git.exe rev-list --no-walk 385630d58f9f32f9032fe522b59dc3b02bffb601 # timeout=10
[newGen_protractor] $ cmd /c call C:\Windows\TEMP\jenkins7617198822539381099.bat

C:\Program Files (x86)\Jenkins\workspace\newGen_protractor>cd NewGenProject/ui/ 

C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui>npm install 
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated [email protected]: Use uuid module instead
npm WARN deprecated [email protected]: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/common@>=6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/core@>=6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN The package protractor is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

audited 7457 packages in 56.372s
found 20 vulnerabilities (2 low, 12 moderate, 6 high)
  run `npm audit fix` to fix them, or `npm audit` for details
[newGen_protractor] $ cmd /c call C:\Windows\TEMP\jenkins4609473287255355323.bat

C:\Program Files (x86)\Jenkins\workspace\newGen_protractor>cd NewGenProject/ui/ 

C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui>npm -g install protractor 
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\protractor -> C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\protractor\bin\protractor
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\webdriver-manager -> C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\protractor\bin\webdriver-manager
+ [email protected]
updated 1 package in 18.629s
[newGen_protractor] $ cmd /c call C:\Windows\TEMP\jenkins7178030739891384049.bat

C:\Program Files (x86)\Jenkins\workspace\newGen_protractor>cd NewGenProject/ui/ 

C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui>npm install -g @angular/cli 
C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\ng -> C:\Windows\system32\config\systemprofile\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @angular/[email protected]
updated 1 package in 41.137s
[newGen_protractor] $ cmd /c call C:\Windows\TEMP\jenkins6289130843578065566.bat

C:\Program Files (x86)\Jenkins\workspace\newGen_protractor>cd NewGenProject/ui/ 

C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui>npm i jasmine-spec-reporter 
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/common@>=6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/core@>=6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN The package protractor is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ [email protected]
updated 1 package and audited 7457 packages in 33.375s
found 20 vulnerabilities (2 low, 12 moderate, 6 high)
  run `npm audit fix` to fix them, or `npm audit` for details
[newGen_protractor] $ cmd /c call C:\Windows\TEMP\jenkins4506427873481134558.bat

C:\Program Files (x86)\Jenkins\workspace\newGen_protractor>cd NewGenProject/ui/ 

C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui>npm i chromedriver 

> [email protected] install C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\chromedriver
> node install.js

Downloading https://chromedriver.storage.googleapis.com/2.41/chromedriver_win32.zip
Saving to C:\Windows\TEMP\chromedriver\chromedriver_win32.zip
Received 781K...
Received 1568K...
Received 2352K...
Received 3136K...
Received 3468K total.
Extracting zip contents
Copying to target path C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\chromedriver\lib\chromedriver
Done. ChromeDriver binary available at C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\chromedriver\lib\chromedriver\chromedriver.exe
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/common@>=6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of @angular/core@>=6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN The package protractor is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ [email protected]
added 6 packages from 4 contributors and audited 7583 packages in 41.593s
found 20 vulnerabilities (2 low, 12 moderate, 6 high)
  run `npm audit fix` to fix them, or `npm audit` for details
[newGen_protractor] $ cmd /c call C:\Windows\TEMP\jenkins4129844378444836330.bat

C:\Program Files (x86)\Jenkins\workspace\newGen_protractor>cd NewGenProject/ui/ 

C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui>ng e2e --no-webdriver-update 
Your global Angular CLI version (6.2.1) is greater than your local
version (1.7.3). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
** NG Live Development Server is listening on localhost:49156, open your browser on http://localhost:49156/ **
[0mDate: [1m[37m2018-09-16T14:59:10.870Z[39m[22m[0m
[0mHash: [1m[37mb824d4ffc831966e2310[39m[22m[0m
[0mTime: [1m[37m47178[39m[22mms[0m
[0mchunk {[1m[33minline[39m[22m} [1m[32minline.bundle.js, inline.bundle.js.map[39m[22m (inline) 3.89 kB [1m[33m[entry][39m[22m[1m[32m [rendered][39m[22m[0m
[0mchunk {[1m[33mmain[39m[22m} [1m[32mmain.bundle.js, main.bundle.js.map[39m[22m (main) 240 kB [1m[33m[initial][39m[22m[1m[32m [rendered][39m[22m[0m
[0mchunk {[1m[33mpolyfills[39m[22m} [1m[32mpolyfills.bundle.js, polyfills.bundle.js.map[39m[22m (polyfills) 203 kB [1m[33m[initial][39m[22m[1m[32m [rendered][39m[22m[0m
[0mchunk {[1m[33mscripts[39m[22m} [1m[32mscripts.bundle.js, scripts.bundle.js.map[39m[22m (scripts) 158 kB [1m[33m[initial][39m[22m[1m[32m [rendered][39m[22m[0m
[0mchunk {[1m[33mstyles[39m[22m} [1m[32mstyles.bundle.js, styles.bundle.js.map[39m[22m (styles) 158 kB [1m[33m[initial][39m[22m[1m[32m [rendered][39m[22m[0m
[0mchunk {[1m[33mvendor[39m[22m} [1m[32mvendor.bundle.js, vendor.bundle.js.map[39m[22m (vendor) 6.04 MB [1m[33m[initial][39m[22m[1m[32m [rendered][39m[22m[0m
(node:3372) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

webpack: Compiled successfully.
[16:59:11] I/direct - Using ChromeDriver directly...
[16:59:11] I/launcher - Running 1 instances of WebDriver
[16:59:11] E/launcher - Error: Error: Could not find chromedriver at C:\Users\<username>\AppData\Roaming\npm\node_modules\protractor\selenium\chromedriver.exe
    at Direct.getNewDriver (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\protractor\built\driverProviders\direct.js:62:27)
    at Runner.createBrowser (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\protractor\built\runner.js:182:43)
    at C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\protractor\built\runner.js:255:30
    at _fulfilled (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\q\q.js:834:54)
    at self.promiseDispatch.done (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\q\q.js:863:30)
    at Promise.promise.promiseDispatch (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\q\q.js:796:13)
    at C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\q\q.js:556:49
    at runSingle (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\q\q.js:137:13)
    at flush (C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\q\q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickCallback (internal/process/next_tick.js:181:9)
[16:59:11] E/launcher - Process exited with error code 100
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
1
This is not useful for me. Any other solutions with out plagin's? - Lee Ji

1 Answers

0
votes

The failure is you install chromedriver by npm i chromedriver which into C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\chromedriver\lib\chromedriver.

But your protractor conf file expect to find it from C:\Users\<username>\AppData\Roaming\npm\node_modules\protractor\selenium\chromedriver.exe

I have to say your protractor conf.js and package.json looks mess.

  1. Duplicate chomedriver and seleniumServerJar setting in conf.js.
  2. Duplicate protractor dependency appeared in dependencies and devDependencies in package.json

Remove all chomedriver and seleniumServerJar in protractor conf.js.

Remove "protractor": "^3.2.2" from package.json, it's a very old version.

Remove "selenium-webdriver": "2.52", from package.json

Remove whole "bin" section from package.json

Add latest @angular/cli and jasmine-spec-reporter as devDependencies of package.json

Change the windows cmd in jenkins job as following:

cd NewGenProject/ui/
npm install
// if your windows machine's chrome browser is compatible with latest chromedrvier, 
// you can omit `--versions.chrome` option
node_modules\.bin\webdriver-manager update
// otherwise you need to specify the compatible version
node_modules\.bin\webdriver-manager update --versions.chrome=<compatible chromedriver version>
ng e2e --no-webdriver-update