运行样本回归测试时出现以下错误:
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"
}
}
来自终端的消息。
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
将套件修改为“套件”确实解决了部分问题。但是收到以下错误消息:
[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$
答案 0 :(得分:4)
发现了问题。
正如https://www.protractortest.org/#/page-objects所建议的那样,您的配置“套件”必须为复数形式,而不是“套件”
在cmd行中,应使用--suite
(而不是--suites
)在配置文件的suites
块中提供您定义的套件名称。
答案 1 :(得分:1)
suite:
{
Smoke : ['ChainLocator.js','dropDowns.js'],
Regression : 'nonAnuglarSpec.js'
},
suite
是一个原始对象,而没有split
方法。这意味着您为suite
指定了无效/意外的类型。