使用Geb测试Angular动态页面内容(ng-if) [英] Testing Angular dynamic page content (ng-if) with Geb
问题描述
我正在尝试使用Geb测试Angular ng-if元素是否可见。到目前为止,我试图测试显示的属性是真还是假,如下所示。
I am trying to test if an Angular ng-if element is visible or not using Geb. So far I've attempted to test if the displayed property is true or false as follows.
Angular:
<article ng-if="!condition" class="bar foo ng-scope">Text to Display</article>
Geb UI模块:
unselectedErrorText { $(class: "bar foo ng-scope") }
测试:
assertThat(unselectedErrorText.displayed).isFalse()
checkBox.value()==false
assertThat(unselectedErrorText.displayed).isTrue()
我收到以下错误:
The required page content 'unselectedErrorText - SimplePageContent' is not present
提前致谢!
推荐答案
我错过的是角度代码生成动态页面内容。 Geb(通过底层selenium)将在执行任何JavaScript操作之前获得初始DOM。
What I had missed was that the Angular code generates dynamic page content. Geb(through the underlying selenium) will just have the initial DOM before any JavaScript manipulation is performed.
我使用 waitFor <解决了这个问题/ a> Geb提供的方法。
I solved this using the waitFor method provided by Geb.
checkbox.value(false)
waitFor("quick") {
assertThat(unselectedErrorText.displayed).isTrue()
}
还有,非常感谢更全面的解释!
Any further, more comprehensive explanation is very much appreciated!
这篇关于使用Geb测试Angular动态页面内容(ng-if)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!