2014-10-16 38 views
1

从列表验证文本循环,标志不量角器 工作,我又怎么可以退出循环的,如果我的条件相匹配在量角器返回值,打破条件

this.verifyAddedItem = function (panelName, searchTerm) { 
    var addedList = element.all(by.xpath('//*[@ng-repeat="selectedTerm"]/div[1]')); 
      var listCount = addedList.count(); 
      //  length is 2  
      listCount.then(function (length) { 
       Flagg = 'NA'; 
       for (var i = 1; i <= length; i++) {    
        addedList.get(i - 1).getText().then(function (termText) { 
         if (termText == searchTerm) { 

          Flagg = 'true'; 
          console.log("FLAGGGGG:= " + Flagg); 
         } else { 

          Flagg = 'false'; 
      `verification`//console.log("FLAG:= " + Flagg); 
         } 
        }) 
       } 
      //validate the value of flag    
       expect(Flagg).toBe('true'); 
       }) 
      } 

回答

0

如果您正在验证某个文本是否存在于下拉列表中:

public verifyDropdownValue(dropdownListLocator, optionText) { 
    var allOptions =element(by.model(dropdownListLocator)). 
       all(by.tagName('option')).getAttribute('value'); 

    expect(allOptions).toContain(optionText); 
}