angular - .type() 将不接受空字符串 cypress
问题描述
我想检查我创建的登录屏幕中是否存在文本“您必须输入一个值”(附截图)。当用户触摸输入字段,然后单击不同的字段或区域而不输入任何内容时,就会出现这种情况。所以我试图用柏树测试它,但它说
".type() will not accept an empty string"
柏:
it('Should display You must enter a value if user does not type anything', () => {
cy.get('#username').type('')
cy.contains('You must enter a value')
})
我需要帮助来解决这个问题,谢谢。
解决方案
确实只是聚焦和模糊:
it('Should display You must enter a value if user does not type anything', () => {
cy.get('#username')
.focus()
.blur()
cy.contains('You must enter a value')
})
推荐阅读
- java - Java 和 Mac OS java -jar
- date - 在pyspark中将字符串转换为日期(格式年季度)
- html - 复选框重叠复选框标签
- javascript - 使用 document.createElement 创建时更改 html 元素在父标签中的位置
- css - 为什么 CSS 颜色在 PowerShell ConvertTo-HTML 电子邮件中消失?
- spring - 允许 bean 实现不定义 getBean 提供的参数
- python - 用 Python 脚本做 ssh 隧道。错误:“尝试打开 ssh 隧道时无法解析主机名”
- ggplot2 - 如何在ggplot r中的组合条形图和线图中标记线图?
- php - PHP 执行查询返回错误的输出
- bash - 剪切命令不重定向