量角器|如何单击具有ng-click属性的div

时间:2016-06-07 11:05:59

标签: javascript html angularjs dom protractor

尝试点击div时,我会继续- Failed: element not visible

Uitlis: openClosedSignElement(){
    $('[ng-click="changeViewToggle(category, taskSetProperty);isOpen = !isOpen"]').click();
}

e2e: it('Should add another task to template successfully', () =>  {
    taskUtils.openClosedSignElement();
}

tried also this inside Utilis: openClosedSignElement(){ 
    browser.element(by.id('addTaskTemplate')).click();
}

Html

<div ng-show="header" id="closeSign" 
     class="closeSign"   ng-init="isOpen = isOpen ? isOpen : false"  
     ng-click="changeViewToggle(category, taskSetProperty);isOpen = !isOpen">
</div>

1 个答案:

答案 0 :(得分:0)

您可以通过检查isDisplayed是否显示元素来实现所需的输出,否则请点击例如head元素然后继续您的断言

$('[ng-show=saving].icon-spin').isDisplayed().then(function(result) { //check whether element is displaye
  if (result) { //if yes go ahead
    $('[ng-click="changeViewToggle(category, taskSetProperty);isOpen = !isOpen"]').click();
  } else { //else by clickin relvent element make it display
    $("#header").click().then(function() {
        $('[ng-click="changeViewToggle(category, taskSetProperty);isOpen = !isOpen"]').click();
      }
    })
})