我正在使用TestCafe,并希望确定checkbox元素是否存在。在HTML元素中,如果复选框已被选中,则属性checked
存在,否则不存在。如何确定是否使用TestCafe?
我使用了TestCafe - .hasAttribute('checked')
中提供的函数,但返回的结果是undefined
。
以下是选中复选框时的HTML代码:
<input class="jss1523" tabindex="-1" type="checkbox" data-indeterminate="false" value checked>
以下是未选中复选框时的HTML代码:
<input class="jss1523" tabindex="-1" type="checkbox" data-indeterminate="false" value>
如何使用TestCafe解决此问题?
发布于 2019-06-27 06:59:39
对于使用Selector()
获得的每个Dom元素,都可以检查属性checked
- https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/dom-node-state.html#members-specific-to-element-nodes
对于复选框和单选输入,它返回布尔值(true
-如果选中,则返回otherwise
- false),而对于其他类型的元素,则返回undefined
https://stackoverflow.com/questions/56778543
复制