赛普拉斯如何断言输入值是真实的 [英] How to assert that input value is truthy with cypress
本文介绍了赛普拉斯如何断言输入值是真实的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些输入
<input />
如何断言输入具有真实价值?
How to assert that input has truthy value?
我认为这可能与
cy('input').should('not.have.value', '')
但我认为这有点不可靠。或者可能不是。但是无论如何,很高兴知道其他方法来检查真实值。
but I think it's slightly unreliable. Or maybe not. But anyway, would be nice to know some other way to check for truthy value.
推荐答案
只是发现调用东西,因此可以这样做:
Just found that invoke thing, so it's possible to do so:
cy.get('input').invoke('val').should("be.ok");
cy.get('input').invoke('val').should('not.be.empty') // works in the same way.
调用是调用函数的方式( jquery命令(在这种情况下)。
invoke is the way to call functions (jquery command in that case).
这篇关于赛普拉斯如何断言输入值是真实的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文