在我的项目中,我创建了一个 protractor.config.js
文件并使用 grunt 驱动它。我想要一个 globalProtractor.conf
和多个 config.js
并将它们像子conf一样维护,以执行不同的测试套件并跳过诸如 Onprepare 函数之类的常见内容或所有conf中的多个容量或全局变量。
在我的 globalprotractor.conf 中,我有
seleniumAddress: {
selenium: 'http:......'
},
我需要在子conf中覆盖它。有什么具体的方法吗?
最佳答案
这是一个很好的问题,我想这在大型测试项目中是一个相当合理的要求。我想出了以下方法。让我知道这是否有效!!
在一处拥有全局配置 - globalConf.js
//Declare all your global configuration here which is common across all suites
var globalConf = {
seleniumAddress: 'http://localhost:4444/wd/hub',
localSeleniumStandaloneOpts: {
jvmArgs: ["-Dwebdriver.ie.driver=C://IEDriverServer_x64_2.53.1.exe"]
},
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 120000,
includeStackTrace: true,
isVerbose: true,
},
capabilities: {
browserName: 'chrome',
},
onPrepare: function () {
browser.getProcessedConfig().then(function(data){
console.log(data);
});
},
allScriptsTimeout: 120000,
getPageTimeout: 120000,
afterLaunch: function (exitCode) {
}
}
//Export the global configuration to be called in local config files
module.exports = globalConf;
然后有多个conf文件,这些文件将导入globalConf并进行特定于套件的更改
conf1.js
//Import Global Configuration file
var globalConf = require('./globalConf.js');
//Clone the global configuration object. You can follow any cloning mechanism
var localConf = JSON.parse(JSON.stringify(globalConf));
//Make custom changes to suit your suite. May be add Suites or anything thats at suite level
localConf['specs'] = 'test.js';
// Set the value of exports.config based on
exports.config = localConf;
conf2.js
//Import Global Configuration file
var globalConf = require('./globalConf.js');
//Clone the global configuration object. You can follow any cloning mechanism
var localConf = JSON.parse(JSON.stringify(globalConf));
//Make custom changes to suit your suite. May be add Suites or anything thats at suite level
localConf['specs'] = 'test2.js';
// Set the value of exports.config based on
exports.config = localConf;
关于javascript - 维护 GlobalProtractorConf 和多个配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43101820/