断言 exists().exists returns 断言评估为 false 即使定位器在 DOM 中可用

Assert exists().exists returns assert evaluated to false even locator is available in DOM

首先感谢空手道-UI。学习空手道后 - API,我们开始使用空手道 UI :-)

让我在这里总结一下我的问题:我从下面的代码中得到 'assert evaluated to false':

* match text({}header) == 'header'
* assert exists({}header).exists

代码的第一行能够定位元素并比较文本,第二行针对同一定位器抛出错误。你能帮我解决这个问题吗?

你能试试 0.9.6.RC3 - 我们意识到 exists() 太混乱了,并更改了 API.

详细解释在这里:https://github.com/intuit/karate/issues/1148

更新的文档在这里:https://github.com/intuit/karate/tree/develop/karate-core#optional

所以你应该这样做:

* assert exists('{}header')

如果您确认这有效,那将对我们有很大帮助。否则请遵循此过程:https://github.com/intuit/karate/tree/develop/examples/ui-test