我正在尝试对我的网站使用 Protractor 测试。当我运行测试时,Firefox 在屏幕上显示来自 ng-view="admin"
(正确 View )的部分“Welcome home soldier”。然而测试结果为失败。
index.html:
<div ui-view="!admin">
<h1> Please sign up </h1>
</div>
<div ui-view="admin">
<h1> Welcome home soldier </h1>
</div>
index_spec.js:
如果我这样做,则测试失败:
expect($('[ui-view="admin"]').isDisplayed()).toBe(true);
如果我这样做那么测试成功:
expect($('[ui-view="admin"]').isDisplayed()).toBe(false);
我尝试执行 isPresent()
,但它给了我相同的结果。
最佳答案
如果尝试这个,你会得到好的结果吗?
browser.wait(function () {
return $('[ui-view="admin"]').isDisplayed();
}, 5000);
expect($('[ui-view="admin"]').isDisplayed()).toBe(true);
关于testing - 如何为 ui-view 或 ng-if 做 Protractor 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44749472/