我可以通过以下方式验证结果页面上的文本是否出现在“某个地方”:
我尝试了
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 :(
})
但是我该如何验证我在中输入的文本呢?
我尝试使用链式方法定位到元素:
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')
})
但我却获得
CypressError: Timed out retrying: Expected to find content: 'abc123' within the element: <input.gLFyf.gsfi> but never did.
我尝试了
cy.get("input[name=q]").contains('abc123')
和cy.contains('input[name=q]', 'abc123')
,但两者都超时失败了。
^
和$
锚点,但该问题已被删除。 - Snow