admin管理员组文章数量:1296505
I am doing some E2E test using cypress and I want to get the date that appears on a DatePicker element from my react app. I tried this but both return an empty string:
cy.get('input[name="Date"]').invoke('attr', 'value').then((text) => {
expect('08/05/2019').to.equal(text);
});
cy.get('input[name="Date"]').invoke(text).then((text) => {
expect('08/05/2019').to.equal(text);
});
I would like to get the value of this DatePicker which is always today by default.
I am doing some E2E test using cypress and I want to get the date that appears on a DatePicker element from my react app. I tried this but both return an empty string:
cy.get('input[name="Date"]').invoke('attr', 'value').then((text) => {
expect('08/05/2019').to.equal(text);
});
cy.get('input[name="Date"]').invoke(text).then((text) => {
expect('08/05/2019').to.equal(text);
});
I would like to get the value of this DatePicker which is always today by default.
Share Improve this question asked May 8, 2019 at 14:59 MarcMarc 4933 gold badges9 silver badges24 bronze badges1 Answer
Reset to default 7Thanks to this post How to get the text input field value to a const and log that value in Cypress.io
I found the answer, it seems I should treat the datepiker input as a text input.
cy.get('input[name="Date"]').invoke('val').then((text) => {
expect('08/05/2019').to.equal(text);
});
本文标签: javascriptHow to get value of a DatePicker CypressStack Overflow
版权声明:本文标题:javascript - How to get value of a DatePicker Cypress - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741638149a2389758.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论