本文介紹了如何讀取參數的值,存在于規格中量角器的 conf.js 文件中的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
例如: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模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!