【问题标题】:Protractor isPresent() result for elements in/with ng-if量角器 isPresent() 结果在/与 ng-if 中的元素
【发布时间】:2016-03-26 21:31:51
【问题描述】:

在我的应用程序中,我有一个控制器,其作用域有一个模型,用于在我的视图中确定条件。非常标准。

控制器

$scope.shouldShow = false;
$scope.seeCoal = true;

查看

<div ng-controller="SomeController" ng-if="shouldShow">
  <span id="coal" ng-show="seeCoal"></span>
</div>

很公平。当我将此shouldShow 更改为真实的东西时,此 div 将呈现。

量角器将如何解释它以及它包含的标记?如果我的测试没有shouldShow 模型设置为true,那么#coal 元素是否会被element.isPresent() 视为存在?

另外,如果(在我的测试中)我确实shouldShow 设置为真(保持为假),并将seeCoal 设置为假 - 我可以遍历到@987654329 @ 以确认 ng-hide 类存在,即使它的父类具有评估为 false 的 ng-if 条件?

在我正在尝试的项目中,我有太多不确定性,我无法确定量角器在这些情况下应该如何工作。

【问题讨论】:

    标签: angularjs protractor


    【解决方案1】:

    Angular 的 ng-if 将从 DOM 中删除其受影响的元素。因此,它们及其子元素不会以任何形式对 Protractor 可见。如果shouldShow 是假的,那么 Protractor 将根本看不到“煤”跨度。

    ng-show 将元素留在 DOM 中,但使其不可见。见what is the difference between ng-if and ng-show/ng-hide

    量角器定位器应该能够找到ng-show-hidden 元素。其承诺上的isDisplayed() 方法应该承诺返回false。见How to use protractor to check if an element is visible?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-19
      • 2016-03-26
      • 2016-10-13
      相关资源
      最近更新 更多