Javascript 我可以让gragrator.config.js中的'seleniumAddress'字段接受参数吗?
我有一个Windows的盒子和一个Ubuntu的盒子,我在上面运行我的自动测试。目前,在我的Javascript 我可以让gragrator.config.js中的'seleniumAddress'字段接受参数吗?,javascript,protractor,Javascript,Protractor,我有一个Windows的盒子和一个Ubuntu的盒子,我在上面运行我的自动测试。目前,在我的grandor.config.js文件中,我的multiCapabilities:[{}]部分下有两个seleniumAddress字段,只需根据我希望在哪个环境中运行,注释其中一个字段即可 有没有一种方法可以参数化seleniumAddress:,这样我就可以从命令行判断要在哪个环境中运行 类似这样:gulpe2e--suite--baseUrl --环境窗口 这是我的量角器配置文件中当前的多电容部分:
grandor.config.js
文件中,我的multiCapabilities:[{}]
部分下有两个seleniumAddress
字段,只需根据我希望在哪个环境中运行,注释其中一个字段即可
有没有一种方法可以参数化seleniumAddress:,这样我就可以从命令行判断要在哪个环境中运行
类似这样:gulpe2e--suite--baseUrl
--环境窗口
这是我的量角器配置文件中当前的多电容
部分:
多容量:[{
browserName:“chrome”,
//seleniumAddress:“指向webdriver管理器窗口框的URL”,
seleniumAddress:“指向webdriver管理器Ubuntu框的URL”,
平台:'任何',
版本:'任何',
色度选项:{
参数:['--no sandbox','--test type=browser','--lang=en','--window size=16801050'],
首选项:{
“凭据\u启用\u服务”:false,
“个人资料”:{
“密码管理器已启用”:false
},
下载:{
提示下载:false,
目录\u升级:true,
默认目录:“C:\\downloads\\'
},
},
}
//shardTestFiles:对,
//最大实例:2
}],
量角器在Node.js上运行,因此您应该能够传递参数(稍微复杂一点),或者更容易地设置环境变量:
添加了环境变量逻辑的来自的量角器配置代码段:
// Use the Windows selenium if the environmental variable IS_WINDOWS is set.
const seleniumServer = process.env.IS_WINDOWS ?
'https://path/to/windows-silenium' : 'https://path-to-default-selenium';
exports.config = {
// The address of a running selenium server.
seleniumAddress: seleniumServer,
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Spec patterns are relative to the configuration file location passed
// to protractor (in this example conf.js).
// They may include glob patterns.
specs: ['example-spec.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true, // Use colors in the command line report.
}
};
我不太确定您想从中选择什么(我不使用gulp),但对于上面的代码片段,您可能会使用:
IS_WINDOWS=true gulp e2e --suite <suiteName> --baseUrl <URL>
IS_WINDOWS=true gulp e2e--suite--baseUrl
非常感谢,我很快会在这里试一试。