Protractor:如何让配置文件更灵活? [英] Protractor: how to make the configuration file more flexible?
本文介绍了Protractor:如何让配置文件更灵活?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个让我的配置更灵活的想法.例如,我有 10000 个具有相同参数的配置文件:
I have an idea to make my configs more flexible. For example I have 10000 config files with same parameters:
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['C:/Users/Lilia.Sapurina/Desktop/Protractor Tests/Scenarios/ps-grid-column-filter-range_spec.js'],
params: {'url_filter': 'http://wks-15103:8010/ps/ng-components/examples/ps-grid-column-filter-range.html'}
一旦我想更改规范、html 的路径或更改 selenium 地址.我可以在另一个文件中为我的所有配置执行此操作吗?
And once I want to change path to specs, html or change selenium address. Can I do this in another file for all my configs?
例如写在我的配置中:
seleniumAddress: '../Variables/seleniumAdress.txt'
或者也许存在其他有趣的方法来解决这个问题?
Or maybe exist another interesting ways to solve this problem?
推荐答案
您可以将常用的配置规则导出为 node.js 模块:
You can export your common config rules as node.js module:
// globalProtractor.conf.js
module.exports = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['C:/Users/Lilia.Sapurina/Desktop/Protractor Tests/Scenarios/ps-grid-column-filter-range_spec.js'],
params: {
'url_filter': 'http://wks-15103:8010/ps/ng-components/examples/ps-grid-column-filter-range.html'
}
并在另一个文件中使用
// protractor.conf.js
var globalConf = require('/path/to/globalProtractor.conf.js');
globalConf.specs.push('path/new.spec.js');
exports.config = globalConf;
这篇关于Protractor:如何让配置文件更灵活?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文