TestCafe— Proper way to assert an element is visible

心不动则不痛 提交于 2020-01-03 10:59:08

问题


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();

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?


回答1:


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:

Smart Assertion Query Mechanism

Or other properties of the element, such as :checked

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



来源:https://stackoverflow.com/questions/51486699/testcafe-proper-way-to-assert-an-element-is-visible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!