在量角器中返回值并在条件下打破循环

时间:2014-10-16 09:59:44

标签: jasmine protractor

  

验证列表中的文本,Flag在量角器中不起作用       如果条件符合

,我怎么能摆脱循环呢?
    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');
                })
            }

1 个答案:

答案 0 :(得分:0)

如果您要确认下拉列表中是否存在某个文字:

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

    expect(allOptions).toContain(optionText);
}