【问题标题】:Return value in protractor and break the loop on condition在量角器中返回值并在条件下打破循环
【发布时间】:2014-10-16 09:59:43
【问题描述】:

验证列表中的文本,标记在量角器中不起作用 另外,如果我的条件匹配,我该如何跳出循环

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

【问题讨论】:

    标签: jasmine protractor


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-18
      相关资源
      最近更新 更多