我的量角器测试通过了,但是当它启动时,我看到了“未定义”。我不知道这是指什么或为什么出现。帮助吗?
test@test-Gazelle:~/git/Protractor$ protractor conf.js
[21:35:46] I/launcher - Running 1 instances of WebDriver
[21:35:46] I/direct - Using ChromeDriver directly...
Started
undefined
...
3 specs, 0 failures
Finished in 12.422 seconds
这是我的代码中对“控制台”的唯一引用- (我是量角器/ Js(茉莉花)的新手,所以我不明白控制台为什么会产生影响)。顺便说一句,此代码永远不会执行。
var tools = require('./tools.js');
console.log(tools.hello());
var closure = tools.retreive();
console.log(closure());
下面是我的conf.js文件-
exports.config = {
directConnect: true,
capabilities: {
browserName: 'chrome',
chromeOptions: {
/*args: ['--window-size=800,1000']*/
}
},
/*capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Version/10.0 Mobile/14A300 Safari/602.1 AmericanAirlines']
}
},*/
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
},
/*
multiCapabilities: [
{
browserName:'firefox'
},
{
browserName:'chrome'
}
],
*/
/*specs: ['testScripts/changeResBackgroundColor.js', 'testScripts/paddingForContinueButton.js'],*/
specs: ['testScripts/testFunctions.js'],
framework: 'jasmine',
onPrepare: function () {
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: './target/',
filePrefix: 'xmlresults'
}));
var fs = require('fs-extra');
fs.emptyDir('./target/screenshots/', function (err) {
console.log(err);
});
jasmine.getEnv().addReporter({
specDone: function (result) {
if (result.status == 'failed') {
browser.getCapabilities().then(function (caps) {
var browserName = caps.get('browserName');
browser.takeScreenshot().then(function (png) {
var stream = fs.createWriteStream('./target/screenshots/' + browserName + '-' + result.fullName + '.png');
stream.write(new Buffer(png, 'base64'));
stream.end();
});
});
}
}
});
},
//HTMLReport called once tests are finished
onComplete: function () {
var browserName, browserVersion;
var capsPromise = browser.getCapabilities();
capsPromise.then(function (caps) {
browserName = caps.get('browserName');
browserVersion = caps.get('version');
platform = caps.get('platform');
var HTMLReport = require('protractor-html-reporter-2');
testConfig = {
reportTitle: 'Protractor Test Execution Report',
outputPath: './target/',
outputFilename: 'ProtractorTestReport',
screenshotPath: './screenshots',
testBrowser: browserName,
browserVersion: browserVersion,
modifiedSuiteName: false,
screenshotsOnlyOnFailure: true,
testPlatform: platform
};
new HTMLReport().from('./target/xmlresults.xml', testConfig);
});
}
};