cypress - 从输入字段获取文本返回对象值而不是文本值
问题描述
我在做最简单的事情时遇到问题:验证字段中的值。
标记:
<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” - 是该字段中的可见文本。当上述方法不起作用时,我该如何获得它?
解决方案
您需要的文档是How-do-I-get-an-input-s-value
// make an assertion on the value
cy.get('input').should('have.value', 'abc')
推荐阅读
- python - 如何从字符串列表中删除引号并将其再次存储为列表..?
- node.js - 将循环字符串转换为 json
- android - 拍摄水平滚动图形视图的屏幕截图
- html - 如何删除视频周围的空白并将其拉伸以填充整个内容?
- react-native - 如何使用 react-native-mapbox-gl 在 react-native 中查找具有格式化地址的最近地点
- ios - 虚拟键盘在 iOS React Native 上不可见
- android - 在另一个活动中调用函数
- javascript - 在 javascript 中使用 == 总是错误的
- selenium - selenium python:驱动程序没有 find_element_by 属性
- powerbi - 是否有任何选项/函数/api 来获取 Power BI 报告中使用的字段(表名和列)?