例如: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;
})
}
这篇关于如何读取参数的值,存在于规格中量角器的 conf.js 文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 javascript 认为文档“准备好"之前,如何让How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 认为文档“准备好
jasmine 运行和等待实际上是做什么的?What do jasmine runs and waitsFor actually do?(jasmine 运行和等待实际上是做什么的?)
如何提供模拟文件来更改 <input type='filHow to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模拟文件来更改 lt;input type=filegt; 的事
如何使用 Jasmine 对链式方法进行单元测试How to unit test a chained method using Jasmine(如何使用 Jasmine 对链式方法进行单元测试)
如何将 $rootScope 注入 AngularJS 单元测试?How do I inject $rootScope into an AngularJS unit test?(如何将 $rootScope 注入 AngularJS 单元测试?)
Jasmine - 如何监视函数中的函数调用?Jasmine - How to spy on a function call within a function?(Jasmine - 如何监视函数中的函数调用?)