根据各种论坛讨论、TestCafe 文档以及尝试比较结果,我仍然不确定哪种是断言页面元素可见的正确(或最佳)方法。
await t.expect(Selector('#elementId').visible).ok();
vs
await t.expect(await Selector('#elementId').visible).ok();
或者这些都是不正确的并且还有另一种更好的方法?这与断言元素存在相比如何?或者元素的其他属性,例如:checked?
实际上,两种变体都是可能的。尽管如此,最好使用第一个,因为第二个变体可能会在获取阶段产生错误。元素状态 https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/dom-node-state.html:
智能断言查询机制 https://devexpress.github.io/testcafe/documentation/test-api/assertions/#smart-assertion-query-mechanism
或者元素的其他属性,例如 :checked
您可以获得元素状态 https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/dom-node-state.html并使用其checked https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/dom-node-state.html#members-specific-to-element-nodes option.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)