我试图在描述函数之间传递一个表示数组的变量,但我没有运气。我以前使用过 Protractor ,但以前从未在描述之间传递变量。任何帮助,将不胜感激。 我梳理了流程页面的堆栈,但找不到解决方案。
我什至尝试将每个描述放入一个函数中,但 Protractor 说找不到规范。
describe('WFN Admin Login Test', function() {
var EC = protractor.ExpectedConditions;
it('Load WFN home page - completed', function() {
browser.get('https://wfn-iat.adp.com/public/index.htm');
expect(browser.getCurrentUrl()).toEqual('https://wfn-iat.adp.com/public/index.htm');
});
var fs = require("fs");
var text = fs.readFileSync("/Users/hoflerj/Desktop/Protractor/clients/clientids.txt").toString('utf-8');
var file = text.split("\n");
console.log(file);
var arrayClient = file;
arrayClient.forEach(function(client){
//call other describe function to pass client variable below
});
});
describe('Get_CycleStatus', function() {
var EC = protractor.ExpectedConditions;
it('Enter Client-ID ', function () {
var search1 = ($$('input[id="toolbarQuickSearch"]').get(0));
browser.wait(EC.elementToBeClickable(search1),20,000).then(function() {
search1.clear().sendKeys('midrfrate'); //----client array variable here
search1.sendKeys(protractor.Key.BACK_SPACE);
browser.sleep(2000);
});
var dropdown = element(by.linkText("midrfrate"));//----client array variable
dropdown.click();
browser.sleep(2000);
});
我最终会做一个循环,以便我可以输入下一个客户名称,任何帮助如何使用 Protractor 执行此操作将是最有帮助的。另外,在设置此全局变量之后,我将如何使用循环将其发送到另一个描述语句?
最佳答案
在您的描述中使用 browser.params.paramName
调用所需的参数(在您的情况下browser.params.arrayClient
)
对于循环,请使用数组或对象,如下所示:
params: {
array:[ {
glob:'arrauClient',
glob2:'blabla'
}]
然后在您的描述中使用 browser.params.glo
调用它
关于javascript - Protractor 在描述函数之间传递变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47700289/