元素 in/with ng-if 的 Protractor isPresent() 结果
Protractor isPresent() result for elements in/with ng-if
在我的应用程序中,我有一个控制器,它的范围有一个模型,用于确定我认为的条件。很标准。
控制器
$scope.shouldShow = false;
$scope.seeCoal = true;
查看
<div ng-controller="SomeController" ng-if="shouldShow">
<span id="coal" ng-show="seeCoal"></span>
</div>
很公平。当我将此 shouldShow
更改为真实的内容时,此 div 将呈现。
量角器将如何解释这个及其包含的标记?如果我的测试 没有 将 shouldShow
模型设置为真,那么 #coal
元素是否会被 element.isPresent()
认为存在?
此外,如果(在我的测试中)我 not 将 shouldShow
设置为 truthy(保持为 false),并将 seeCoal
设置为 false -我是否能够遍历到 #coal
以确认 ng-hide
class 存在,即使它的父项具有计算为 false 的 ng-if
条件?
在我尝试这个的项目中,我有太多的不确定性,我不能确定量角器在这些情况下应该如何工作。
Angular 的 ng-if
将从 DOM 中删除其受影响的元素。因此,它们及其子元素将不会以任何形式对 Protractor 可见。如果 shouldShow
是假的,量角器将根本看不到“煤”跨度。
ng-show
在 DOM 中留下一个元素,但使其不可见。参见 what is the difference between ng-if and ng-show/ng-hide。
量角器定位器应该能够找到 ng-show
隐藏元素。 isDisplayed()
方法在它的承诺中应该承诺 return false。参见 How to use protractor to check if an element is visible?
在我的应用程序中,我有一个控制器,它的范围有一个模型,用于确定我认为的条件。很标准。
控制器
$scope.shouldShow = false;
$scope.seeCoal = true;
查看
<div ng-controller="SomeController" ng-if="shouldShow">
<span id="coal" ng-show="seeCoal"></span>
</div>
很公平。当我将此 shouldShow
更改为真实的内容时,此 div 将呈现。
量角器将如何解释这个及其包含的标记?如果我的测试 没有 将 shouldShow
模型设置为真,那么 #coal
元素是否会被 element.isPresent()
认为存在?
此外,如果(在我的测试中)我 not 将 shouldShow
设置为 truthy(保持为 false),并将 seeCoal
设置为 false -我是否能够遍历到 #coal
以确认 ng-hide
class 存在,即使它的父项具有计算为 false 的 ng-if
条件?
在我尝试这个的项目中,我有太多的不确定性,我不能确定量角器在这些情况下应该如何工作。
Angular 的 ng-if
将从 DOM 中删除其受影响的元素。因此,它们及其子元素将不会以任何形式对 Protractor 可见。如果 shouldShow
是假的,量角器将根本看不到“煤”跨度。
ng-show
在 DOM 中留下一个元素,但使其不可见。参见 what is the difference between ng-if and ng-show/ng-hide。
量角器定位器应该能够找到 ng-show
隐藏元素。 isDisplayed()
方法在它的承诺中应该承诺 return false。参见 How to use protractor to check if an element is visible?