admin管理员组文章数量:1391974
I am using Vuetify JS to create UI ponents in my VueJS app. Also I am using CypressJS as testing framework to test these UI ponents. One of the functionality I wish to test is simple check actions on these checkboxs.
As per the cypress documentation I gave these checkboxes a data-cy attribute like
<v-checkbox data-cy="app-checkbox>".
However, in the cypress test, when I refer this element with selector like
cy.get('[data-cy="app-checkbox"]').check({force: true});
the cypress is throwing and error as
CypressError: cy.check() can only be called on :checkbox and :radio. Your subject contains a: <div class="v-input v-input--selection-controls v-input--checkbox v-input--is-label-active v-input--is-dirty" data-cy="app-layer-checkbox">...</div>
p.s. I think this problem is similar to this and this problem, yet even using the jQuery selector I am not able to perform the check on this element.
Any suggestion on how to solve this will certainly help.
Thanks :)
I am using Vuetify JS to create UI ponents in my VueJS app. Also I am using CypressJS as testing framework to test these UI ponents. One of the functionality I wish to test is simple check actions on these checkboxs.
As per the cypress documentation I gave these checkboxes a data-cy attribute like
<v-checkbox data-cy="app-checkbox>".
However, in the cypress test, when I refer this element with selector like
cy.get('[data-cy="app-checkbox"]').check({force: true});
the cypress is throwing and error as
CypressError: cy.check() can only be called on :checkbox and :radio. Your subject contains a: <div class="v-input v-input--selection-controls v-input--checkbox v-input--is-label-active v-input--is-dirty" data-cy="app-layer-checkbox">...</div>
p.s. I think this problem is similar to this and this problem, yet even using the jQuery selector I am not able to perform the check on this element.
Any suggestion on how to solve this will certainly help.
Thanks :)
Share Improve this question edited Jul 11, 2018 at 16:18 Suraj asked Jul 11, 2018 at 13:33 SurajSuraj 5211 gold badge9 silver badges17 bronze badges 1-
It is clear from what you show that the Dom at runtime contains a div and not an
<input type="checkbox">
. It would be nice ifcy.check()
just set thechecked
property and ignored the element type, but in lieu of that you can use.invoke('attr', 'checked', true)
. You should inspect the DOM in devtools to see which element has the checked attribute (check your box and see the changes flash in devtools). That is the element to target in yourcy.get()
. – user8745435 Commented Jul 12, 2018 at 7:35
1 Answer
Reset to default 7I had a similar problem and I find a workaround :
cy.get('input[data-cy=app-checkbox]')
.parent()
.click();
本文标签: javascriptCypressVuetify checkbox not identifiedStack Overflow
版权声明:本文标题:javascript - Cypress + Vuetify checkbox not identified - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744681661a2619446.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论