我可以验证文本出现在结果页面的“某处”
it.only('can verify an input element has certain text typed into it', function() {
cy.visit('http://google.com')
cy.get("input[name=q]").type('abc123{enter}') // with or without the {enter}
cy.contains('abc123') // Anywhere on the page :(
})
Run Code Online (Sandbox Code Playgroud)
但如何验证我在输入文本框中输入的文本?
我尝试链接到元素
it.only('can verify an input element has certain text typed into it', function() {
cy.visit('http://google.com')
cy.get("input[name=q]").type('abc123{enter}')
cy.get("input[name=q]").contains('abc123')
})
Run Code Online (Sandbox Code Playgroud)
但我得到
CypressError: Timed out retrying: Expected to find content: 'abc123' within the element: <input.gLFyf.gsfi> but never did.
Run Code Online (Sandbox Code Playgroud)
我尝试过cy.get("input[name=q]").contains('abc123'),
cy.contains('input[name=q]', 'abc123')
但都超时并失败。
Mic*_*ant 18
更改.contains使用.should('have.value'...
cy.get("input[name=q]").type('abc123{enter}')
cy.get("input[name=q]").should('have.value', 'abc123')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19055 次 |
| 最近记录: |