Mar*_*arc 3 javascript node.js cypress
我正在使用 cypress 进行一些 E2E 测试,我想从我的 React 应用程序中获取出现在 DatePicker 元素上的日期。我试过这个,但都返回一个空字符串:
cy.get('input[name="Date"]').invoke('attr', 'value').then((text) => {
expect('08/05/2019').to.equal(text);
});
Run Code Online (Sandbox Code Playgroud)
cy.get('input[name="Date"]').invoke(text).then((text) => {
expect('08/05/2019').to.equal(text);
});
Run Code Online (Sandbox Code Playgroud)
我想获得这个 DatePicker 的值,默认情况下它总是今天。
感谢这篇文章How to get the text input field value to a const and log the value in Cypress.io
我找到了答案,看来我应该将 datepiker 输入视为文本输入。
cy.get('input[name="Date"]').invoke('val').then((text) => {
expect('08/05/2019').to.equal(text);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9720 次 |
| 最近记录: |