【问题标题】:Can not click checkbox with element from by.repeater无法单击带有来自 by.repeater 元素的复选框
【发布时间】:2017-04-10 22:37:45
【问题描述】:

由于某种原因,我无法单击带有by.repeater 的复选框。没有错误。查看浏览器时,复选框根本没有被选中。有任何想法吗?如果可能的话,我想留在by.repeater

  this.modelChoices = function(rowNumber) {
    return element.all(by.repeater('model in vehicleCheckboxes.models'));
  } 

  checkboxes.modelChoices().get(0).click();

【问题讨论】:

    标签: angularjs selenium protractor angularjs-e2e e2e-testing


    【解决方案1】:

    给定:

    <div>
        <div class="input-group" ng-repeat="item in vm.dataFiles | filter:vm.query">
            <span class="input-group-addon">
                <input type="checkbox" ng-model="item.isChecked">
            </span>
            <label class="form-control">{{item.name}}</label>
        </div>
    </div>
    

    这是我的 e2e 测试的一部分,可能会在某种程度上对您有所帮助。 请注意,我的复选框绑定到“item.isChecked”

    it("should disable the create button when there are no checked items in the vm.dataFiles", function () {
        var dataFiles = element.all(by.repeater("item in vm.dataFiles"));
        var firstCheckbox = dataFiles.get(0).element(by.model("item.isChecked"));
        var btnCreate = element(by.id("btnCreate"));
    
        expect(btnCreate.isEnabled()).not.toBeTruthy();
        firstCheckbox.click();
        expect(btnCreate.isEnabled()).toBeTruthy();
        firstCheckbox.click();
        expect(btnCreate.isEnabled()).not.toBeTruthy();
    });
    

    【讨论】:

      猜你喜欢
      • 2019-02-19
      • 1970-01-01
      • 2015-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-03
      • 1970-01-01
      相关资源
      最近更新 更多