我是詹金斯的新人。我想在詹金斯(Jenkins)工作中自动运行我的量角器测试。我在使用ChromeDriver时遇到问题。 这是我的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'
}));
}
};
这是我的package.js文件:
{
"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"
}
}
在我的Jenkins工作中,我从BitBucket存储库中提取代码。然后执行Windows批处理命令:
我在控制台中出错:
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://___somi@bitbucket.org/night_riders/desingstudio_new_gen.git # timeout=10
Fetching upstream changes from https://___somi@bitbucket.org/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://___somi@bitbucket.org/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 minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN @angular/http@5.2.11 requires a peer of @angular/core@5.2.11 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/http@5.2.11 requires a peer of @angular/platform-browser@5.2.11 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-bootstrap@3.0.1 requires a peer of @angular/common@>=6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-bootstrap@3.0.1 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: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: 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
+ protractor@5.4.1
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: fsevents@1.2.4 (node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ @angular/cli@6.2.2
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/http@5.2.11 requires a peer of @angular/core@5.2.11 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/http@5.2.11 requires a peer of @angular/platform-browser@5.2.11 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-bootstrap@3.0.1 requires a peer of @angular/common@>=6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-bootstrap@3.0.1 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: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ jasmine-spec-reporter@4.2.1
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
> chromedriver@2.41.0 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/http@5.2.11 requires a peer of @angular/core@5.2.11 but none is installed. You must install peer dependencies yourself.
npm WARN @angular/http@5.2.11 requires a peer of @angular/platform-browser@5.2.11 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-bootstrap@3.0.1 requires a peer of @angular/common@>=6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-bootstrap@3.0.1 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: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ chromedriver@2.41.0
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
答案 0 :(得分:0)
失败是您通过npm i chromedriver
安装chromedriver到C:\Program Files (x86)\Jenkins\workspace\newGen_protractor\NewGenProject\ui\node_modules\chromedriver\lib\chromedriver
中。
但是您的量角器conf文件希望从C:\Users\<username>\AppData\Roaming\npm\node_modules\protractor\selenium\chromedriver.exe
中找到它
我不得不说您的量角器conf.js和package.json看起来一团糟。
chomedriver
和seleniumServerJar
设置。protractor
依赖性出现在package.json的dependencies
和devDependencies
中删除量角器conf.js中的所有chomedriver
和seleniumServerJar
。
从"protractor": "^3.2.2"
中删除package.json
,这是一个非常旧的版本。
从"selenium-webdriver": "2.52",
删除package.json
从"bin"
删除整个package.json
部分
添加最新的@angular/cli
和jasmine-spec-reporter
作为devDependencies
中的package.json
按如下所示更改jenkins作业中的Windows cmd:
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