量角器在描述函数之间传递变量

时间:2017-12-07 17:11:02

标签: javascript jasmine protractor jasmine2.0

我试图在描述函数之间传递一个表示数组的变量,但我没有运气。我之前使用过量角器但从未在之前的描述之间传递变量。任何帮助,将不胜感激。 我在流程页面上梳理了堆栈,找不到解决方案。

我甚至尝试将每个描述都放到一个函数中,但是量角器说没有找到规格。

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);



});

enter image description here 我最终会做一个循环,以便我可以输入下一个客户名称任何帮助如何使用量角器这将是最有帮助的。在设置这个全局变量之后,我将如何使用循环将其发送到另一个描述语句?

1 个答案:

答案 0 :(得分:1)

在您的描述中,使用browser.params.paramName(在您的情况下为browser.params.arrayClient)中调用所需的参数

对于循环,使用数组或类似的对象:

params: {
    array:[ {
      glob:'arrauClient',
      glob2:'blabla'
    }]

然后在您的描述中使用browser.params.glo

调用它