如何读取参数的值,存在于规格中量角器的 conf.js 文件中
例如:conf.js
exports.config = {
directConnect: false,
// multiCapabilities: [{
// browserName: 'firefox'
// }, {
// browserName: 'chrome'
// }, {
// browserName: 'internet explorer'
// }],
specs: ['Specs/spec.js'],
seleniumAddress: 'http://localhost:4444/wd/hub',
}
规格:
it('should be able to select the required organization', function() {
Select_Organization.selectOrganization();
//console.log(browser.seleniumAddress);
//This is where I need to read the config paramater values, but above is printing undefined.
expect(browser.getTitle()).toEqual('p3 by NextGen - CSR & Development Capital Management Platform');
});
我需要读取 conf.js 文件中存在的参数值,以便我可以在 specs.js 文件中读取它们以根据 conf.js 中传递的参数值采取必要的操作.有没有办法可以做到这一点.
I need to read the parameter's value present in the conf.js file, so that I can read them in specs.js file to take necessary actions based on the parameter;'s value passed in the conf.js. Is there a way in which this can be possible.
推荐答案
是的,您可以使用 browser.getProcessedConfig
访问所有配置值.检查 这里了解更多详情
Yes, you can access all the config values using browser.getProcessedConfig
.Check here for more details
下面的例子
describe('test', function(){
it('test', function(){
browser.get('http://www.way2automation.com/angularjs-protractor/registeration/#/login');
browser.getProcessedConfig().then(function(config){
console.log(config.baseUrl) // Print Url
console.log(config.specs) // Prints specs
console.log(config.capabilities) // Prints capabilities
})
browser.sleep(10000)
});
});
如果您希望使其可重复使用
In case you are looking to make it re-usable
this.getConfParameterValue = function() {
return browser.getProcessedConfig().then(function(config) {
return config.directConnect;
})
}
相关文章