【发布时间】:2021-04-19 17:26:33
【问题描述】:
我在做最简单的事情时遇到问题:验证字段中的值。
标记:
<input class="hb-inputfelt data-e2e-selector="boligbetegnelse" ng-reflect-form="[object Object]" id="finansieringsobjekt-boligbetegnelse-211-H01-0">
赛普拉斯:
.should('have.text', 'value');
或
.should('have.value', '123'):
返回
expected '<div>' to have value '123', but the value was ''
和
.should('have.text', '123');
返回
expected '<div>' to have text '123', but the text was
'a bunch of text - probably values from the object in ng-reflect-from=[object Object]
我猜问题出在字段中的对象,因为它返回的数据由来自前端“后面”对象的一长串对象值组成。
但我正在检查的值 - “123” - 是字段中的可见文本。上面的方法不行怎么办?
【问题讨论】:
-
你能添加更多的标记来覆盖这个值吗?我猜
invoke('attr', 'value')会得到想要的结果。 Invoke reference -
用 cy.log() 给出结果 '[object Object]';
-
请显示完整的 Cypress 命令,否则您的问题不完整且晦涩。
标签: cypress input-field