TestCafe-断言元素的正确方法是可见的 [英] TestCafe-- Proper way to assert an element is visible

查看:225
本文介绍了TestCafe-断言元素的正确方法是可见的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于各种论坛讨论,TestCafe文档,并尝试将其与结果进行比较,我仍然不确定哪种是断言页面元素可见的正确(或最佳方法).

Based on various forum discussions, the TestCafe documentation, and trying it out to compare results, I am still not certain which is the correct (or best) way to assert that a page element is visible.

await t.expect(Selector('#elementId').visible).ok();

vs

await t.expect(await Selector('#elementId').visible).ok();

还是这些都不正确,还有另一种方法更可取?与断言元素存在相比,这有何不同?或元素的其他属性,例如:checked?

Or are these both incorrect and there is another way that is preferable? How does this compare to asserting that an element exists? Or other properties of the element, such as :checked?

推荐答案

实际上,两种变体都是可能的.不过,最好使用第一个,因为第二个变体在获取

Actually, both variants are possible. Nevertheless, it is better to use the first one because the second variant may raise errors at the stage of obtaining the Element State:

智能声明查询机制

元素的其他属性,例如:checked

Or other properties of the element, such as :checked

您可以获取元素状态,并使用其

You can obtain the Element State and use its checked option.

这篇关于TestCafe-断言元素的正确方法是可见的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆