继续获取TypeError:config.suite.split在运行回归测试时不是功能
2018-11-07
810
我在运行示例回归测试时收到以下错误:
TypeError: config.suite.split is not a function
这是配置文件。它看起来不错,但我肯定遗漏了一些东西,但我真的找不到它是什么。
Configuration.js 文件 (几天前还可以用)
var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['PageObjectLocator2.js'],
capabilities: {
browserName: 'chrome'
},
onPrepare: function() {
browser.driver.manage().window().maximize();
jasmine.getEnv().addReporter(
new Jasmine2HtmlReporter({
savePath: 'target/screenshots'
})
);
},// end of onPrepare
suite:
{
Smoke : ['ChainLocator.js','dropDowns.js'],
Regression : 'nonAnuglarSpec.js'
},
//Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true, // Use colors in the command line report.
}
}
这是 package.json 文件 。可能是这里的问题,但老实说,我不知道
{
"name": "LocatorTraining",
"dependencies": {
"protractor": "^5.4.1",
"jasmine-data-provider": "^2.2.0",
"protractor-jasmine2-html-reporter":"^0.0.7"
},
"scripts": {
"webdriver-update": "./node_modules/.bin/webdriver-manager update",
"webdriver-start": "./node_modules/.bin/webdriver-manager start",
"protractor": "./node_modules/.bin/protractor configurations.js",
"SmokeTest": "./node_modules/.bin/protractor configurations.js --suite Smoke",
"RegressionTest": "./node_modules/.bin/protractor configurations.js --suite Regression",
"start": "npm run webdriver-update && npm run webdriver-start"
}
}
来自 termaminal 的消息。
Jacquelines-MacBook-Air:LocatorTraining jacquelinegeorge$ npm run RegressionTest
> LocatorTraining@ RegressionTest /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining
> protractor configurations.js --suite Regression
/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:155
throw e;
^
TypeError: config.suite.split is not a function
at Function.getSpecs (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/configParser.js:86:26)
at new TaskScheduler (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/taskScheduler.js:34:100)
at helper.runFilenameOrFn_.then.then.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/launcher.js:175:25)
at _fulfilled (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:834:54)
at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:863:30
at Promise.promise.promiseDispatch (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:796:13)
at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:604:44
at runSingle (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:137:13)
at flush (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:125:13)
at internalTickCallback (internal/process/next_tick.js:70:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! LocatorTraining@ RegressionTest: `protractor configurations.js --suite Regression`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the LocatorTraining@ RegressionTest 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! /Users/jacquelinegeorge/.npm/_logs/2018-11-07T14_32_24_804Z-debug.log
将 suite 修改为“suites”确实解决了部分问题。但是收到以下错误消息:
[21:38:02] I/launcher - Running 1 instances of WebDriver
[21:38:02] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
Started
F
Failures:
1) Opening non Angular website Opening google page
Message:
WebDriverError: unknown error: failed to change window state to maximized, current state is normal
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
Stack:
WebDriverError: unknown error: failed to change window state to maximized, current state is normal
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.13.6 x86_64)
at Object.checkLegacyResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/http.js:441:30)
at process.internalTickCallback (internal/process/next_tick.js:77:7)
From: Task: WebDriver.manage().window().maximize()
at thenableWebDriverProxy.schedule (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:807:17)
at Window.maximize (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/selenium-webdriver/lib/webdriver.js:1686:25)
at onPrepare (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/configurations.js:11:37)
at q_1.Promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:46:49)
at Function.promise (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:682:9)
at Object.runFilenameOrFn_ (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/util.js:38:16)
at plugins_.onPrepare.then (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/protractor/built/runner.js:98:27)
at _fulfilled (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:834:54)
at /Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:863:30
at Promise.promise.promiseDispatch (/Users/jacquelinegeorge/Documents/JSworkspace/LocatorTraining/node_modules/q/q.js:796:13)
1 spec, 1 failure
Finished in 0.143 seconds
[21:38:06] I/launcher - 0 instance(s) of WebDriver still running
[21:38:06] I/launcher - chrome #01 failed 1 test(s)
[21:38:06] I/launcher - overall: 1 failed spec(s)
[21:38:06] E/launcher - Process exited with error code 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! LocatorTraining@ RegressionTest: `protractor configurations.js --suite Regression`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the LocatorTraining@ RegressionTest 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! /Users/jacquelinegeorge/.npm/_logs/2018-11-07T21_38_06_831Z-debug.log
Jacquelines-MacBook-Air:LocatorTraining jacquelinegeorge$
2个回答
正如
https://www.protractortest.org/#/page-objects
所建议的那样,您的配置的
suites
必须是复数,而不是
suite
但是在 cmd 行中,您应该使用
--suite
(而不是
--suites
)来提供您在配置文件中的
suites
块中定义的套件名称。
Sergey Pleshakov
2018-11-07
suite:
{
Smoke : ['ChainLocator.js','dropDowns.js'],
Regression : 'nonAnuglarSpec.js'
},
suite
是一个普通对象,并且没有
split
方法。这意味着您为
suite
指定了无效/意外的类型。
Madbreaks
2018-11-07