赛普拉斯如何断言输入值是真实的

时间:2019-08-28 13:12:24

标签: cypress

我有一些意见

<input />

如何断言输入具有真实价值?

我认为

是可能的
cy('input').should('not.have.value', '')

但是我认为这有点不可靠。或者可能不是。但是无论如何,很高兴知道一些其他方法来检查真实值。

3 个答案:

答案 0 :(得分:1)

刚刚发现了invoke件事,因此可以这样做:

cy.get('input').invoke('val').should("be.ok");
cy.get('input').invoke('val').should('not.be.empty') // works in the same way.

调用是调用函数的方式(在这种情况下为jquery command)。

答案 1 :(得分:0)

有多种解决方案,您也可以使用:

cy.('input').should('not.be.empty')

检查值是否不是空字符串比实际要强。

答案 2 :(得分:0)

类似的方法也可以:

<?xml version="1.0" encoding="UTF-8"?>
<RAPPORT>
    <reason>debut test_test_145**PUI** et test 151 _fin test</reason>
</RAPPORT>