我正在尝试使用Courgette测试Angular Web应用程序。这是我的第一次,所以我从here开始学习教程:
问题是我什至不能运行内置测试。这是我的conf.js:
const path = require('path');
require('babel-core/register');
const specsPath = 'uiTests';
const outputPath = 'uiTestResult';
const cukeTractorPath = 'node_modules/cucumber-protractor/uiTestHelpers';
exports.pomConfig = {
outputPath,
timeoutInSeconds: 10,
pagesPath: path.resolve(specsPath, 'pages'),
componentsPath: path.resolve(specsPath, 'components'),
baseUrl: 'https://www.google.com/', // <------------ SET THE URL TO YOUR PROJECT HERE
};
exports.cucumberHtmlReporterConfig = {};
const cukeTags = process.env.cukeTags ? process.env.cukeTags.replace(',', ' or ') : '';
const protractorConfig = {
directConnect: true,
ignoreUncaughtExceptions: true,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
specs: [
`${specsPath}/features/**/*.feature`,
],
capabilities: {
// acceptInsecureCerts: true, // uncomment to ignore SSL warnings
'shardTestFiles': !cukeTags && !process.env.linearise && !process.env.showStepDefinitionUsage,
'maxInstances': 4,
browserName: 'chrome',
chromeOptions: {
args: ['--window-size=1100,800'].concat(process.env.disableHeadless ? [] : ['--headless', '--disable-gpu']),
},
// 'browserName': 'firefox',
// 'moz:firefoxOptions': {
// args: [].concat(process.env.disableHeadless ? [] : ['-headless']),
// prefs: {
// 'general.useragent.override': 'Automated tests',
// },
// },
},
cucumberOpts: {
'require': [
// `${specsPath}/helpers/globals.js`,
`${cukeTractorPath}/globals.js`,
`${cukeTractorPath}/hooks/attachScenarioNameBefore.js`,
`${cukeTractorPath}/hooks/attachScreenshotAfter.js`,
`${cukeTractorPath}/hooks/pageObjectModelBefore.js`,
`${cukeTractorPath}/hooks/addMethodsBefore.js`,
`${cukeTractorPath}/hooks/setDefaultTimeout.js`,
`${cukeTractorPath}/stepDefinitions/*.js`,
`${specsPath}/stepDefinitions/*.js`,
// `${specsPath}/helpers/hooks.js`,
],
'tags': ['~ignore'].concat(cukeTags || []),
'format': [
'node_modules/cucumber-protractor/cucumberFormatter.js',
`json:./${outputPath}/report.json`,
].concat(process.env.showStepDefinitionUsage ? 'node_modules/cucumber/lib/formatter/usage_formatter.js' : []),
'profile': false,
'no-source': true,
},
onPrepare: () => { browser.ignoreSynchronization = true; },
};
exports.config = protractorConfig;
这是终端发出的消息:
> c10@1.0.0 ct C:\Users\Melinda\Desktop\Protractor\c10
> set NODE_OPTIONS=--no-deprecation | cuketractor
Brm brm... off we go!
[09:04:34] I/launcher - Running 1 instances of WebDriver
[09:04:34] I/direct - Using ChromeDriver directly...
DevTools listening on ws://127.0.0.1:12249/devtools/browser/748be31e-7dd6-4f56-95d5-eba8122e4012
Test feature::: Clicking I’m Feeling Lucky without typing a search query goes straight to doodles
Getting full url: https://www.google.com/
Given I am on the 'Google Home' page ---> PASSED
[09:04:38] W/element - more than one element found for locator By(css selector, [name="btnI"]) - the first result will be used
When I click 'I’m Feeling Lucky' ---> FAILED
Then I expect the url to contain 'google.com/doodles' ---> SKIPPED
Screenshot of: Clicking I’m Feeling Lucky without typing a search query goes straight to doodles
*************************************
ScreenshotFilePath:
uiTestResult\Clicking-I’m-Feeling-Lucky-without-typing-a-search-query-goes-straight-to-doodles-1558944278600.png
*************************************
-------------------------------------
---FAIL---
[09:04:38] I/launcher - 0 instance(s) of WebDriver still running
[09:04:38] I/launcher - chrome #01 failed 1 test(s)
[09:04:38] I/launcher - overall: 1 failed spec(s)
[09:04:38] E/launcher - Process exited with error code 1
Cucumber HTML report C:\Users\Melinda\Desktop\Protractor\c10\uiTestResult\cucumberReport.html generated successfully.
------------------ Scenario Error --------------- Clicking I’m Feeling Lucky without typing a search query goes straight
to doodles
Tags: @google, @google-feeling-lucky
Step: When I click 'I’m Feeling Lucky'
Location: node_modules\cucumber-protractor\uiTestHelpers\stepDefinitions\commonWhenSteps.js:46
Feature: uiTests\features\google.feature:4
Error message: ElementNotVisibleError: element not visible
(Session info: headless chrome=74.0.3729.169)
(Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.17134 x86_64)
at Object.checkLegacyResponse (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: WebElement.click()
at Driver.schedule (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
at WebElement.schedule_ (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\selenium-webdriver\lib\webdriver.js:2010:25)
at WebElement.click (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\selenium-webdriver\lib\webdriver.js:2092:17)
at actionFn (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\protractor\built\element.js:89:44)
at Array.map (<anonymous>)
at actionResults.getWebElements.then (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\protractor\built\element.js:461:65)
at ManagedPromise.invokeCallback_ (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\selenium-webdriver\lib\promise.js:1376:14)
at TaskQueue.execute_ (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\selenium-webdriver\lib\promise.js:3084:14)
at TaskQueue.executeNext_ (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\selenium-webdriver\lib\promise.js:3067:27)
at asyncRun (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\selenium-webdriver\lib\promise.js:2927:27)
at C:\Users\Melinda\Desktop\Protractor\c10\node_modules\selenium-webdriver\lib\promise.js:668:7
at process._tickCallback (internal/process/next_tick.js:68:7)Error
at ElementArrayFinder.applyAction_ (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\protractor\built\element.js:459:27)
at ElementArrayFinder.(anonymous function).args [as click] (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\protractor\built\element.js:91:29)
at ElementFinder.(anonymous function).args [as click] (C:\Users\Melinda\Desktop\Protractor\c10\node_modules\protractor\built\element.js:831:22)
-----SCREENSHOT - hold cmd (on mac) and click .png below if using iterm ----
ScreenshotFilePath: uiTestResult\Clicking-I’m-Feeling-Lucky-without-typing-a-search-query-goes-straight-to-doodles-1558944278600.png
---------
┌─────────────────┬────────────┬──────────┐
│ Total Scenarios │ Successful │ Failures │
├─────────────────┼────────────┼──────────┤
│ 1 │ 0 │ 1 │
└─────────────────┴────────────┴──────────┘
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! c10@1.0.0 ct: `set NODE_OPTIONS=--no-deprecation | cuketractor`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the c10@1.0.0 ct script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Melinda\AppData\Roaming\npm-cache\_logs\2019-05-27T08_04_38_705Z-debug.log
还有我的日志文件:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\Melinda\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'ct' ]
2 info using npm@6.9.0
3 info using node@v10.15.3
4 verbose run-script [ 'prect', 'ct', 'postct' ]
5 info lifecycle c10@1.0.0~prect: c10@1.0.0
6 info lifecycle c10@1.0.0~ct: c10@1.0.0
7 verbose lifecycle c10@1.0.0~ct: unsafe-perm in lifecycle true
8 verbose lifecycle c10@1.0.0~ct: PATH: C:\Users\Melinda\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Melinda\Desktop\Protractor\c10\node_modules\.bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Melinda\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Taurus\bin;C:\Program Files\Taurus\bin;C:\Program Files\Java\jdk-10.0.2\bin;C:\Program Files\Java\jre-10.0.2\bin;C:\Users\Melinda\Downloads\apache-jmeter-4.0\apache-jmeter-4.0\bin;C:\Users\Melinda\AppData\Local\Taurus\bin;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\Git\cmd;C:\Program Files\nodejs;C:\Users\Melinda\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Melinda\AppData\Roaming\npm
9 verbose lifecycle c10@1.0.0~ct: CWD: C:\Users\Melinda\Desktop\Protractor\c10
10 silly lifecycle c10@1.0.0~ct: Args: [ '/d /s /c',
10 silly lifecycle 'set NODE_OPTIONS=--no-deprecation | cuketractor' ]
11 silly lifecycle c10@1.0.0~ct: Returned: code: 1 signal: null
12 info lifecycle c10@1.0.0~ct: Failed to exec ct script
13 verbose stack Error: c10@1.0.0 ct: `set NODE_OPTIONS=--no-deprecation | cuketractor`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Users\Melinda\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:189:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Users\Melinda\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:189:13)
13 verbose stack at maybeClose (internal/child_process.js:970:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid c10@1.0.0
15 verbose cwd C:\Users\Melinda\Desktop\Protractor\c10
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Melinda\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "ct"
18 verbose node v10.15.3
19 verbose npm v6.9.0
20 error code ELIFECYCLE
21 error errno 1
22 error c10@1.0.0 ct: `set NODE_OPTIONS=--no-deprecation | cuketractor`
22 error Exit status 1
23 error Failed at the c10@1.0.0 ct script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
我什至不知道问题出在哪里。根据错误消息,找不到我的“何时”部分中的元素,但chrome甚至没有打开。
有人可以帮忙吗?
答案 0 :(得分:0)
这可能是因为该示例当时已损坏,或者您的语言环境与en-gb不同,并且按钮中的文本错误。不是最可靠的样本,理想情况下需要更改为更稳定的样本,由小胡瓜托管。