简体   繁体   English

赛普拉斯 - cmd 运行的不可见元素

[英]Cypress - not visible element for cmd run

When I start my automated test with cmd (via command cypress run) test allways fails with typing in element.当我使用 cmd(通过命令 cypress run)开始我的自动化测试时,测试总是失败并输入元素。 It says that element is not visible.它说该元素不可见。 But when I start my test with browser it will allways pass.但是当我用浏览器开始测试时,它总是会通过。

在此处输入图像描述

Have someone same problem?有人有同样的问题吗?

I can't change HTML code.我无法更改 HTML 代码。

cy.get('#reasonRecommendationByAgent')
.type('Zdůvodnění doporučení zprostředkovatele')
.should('have.value', 'Zdůvodnění doporučení zprostředkovatele')

If I use force:true than test fails with this error message:如果我使用 force:true 则测试失败并显示以下错误消息:

在此处输入图像描述

Thanks for all your help.感谢你的帮助。

This happens because it is masked by some other element.发生这种情况是因为它被其他一些元素掩盖了。 I have seen this happen in my own environment and solved it by simple adding the option 'force'.我已经看到这种情况发生在我自己的环境中,并通过简单地添加选项“force”来解决它。 What you end up with is this:你最终得到的是:

cy.get('#reasonRecommendationByAgent')
  .type('Zdůvodnění doporučení zprostředkovatele', {force: true})
  .should('have.value', 'Zdůvodnění doporučení zprostředkovatele')

I fixed this problem by adding a should('be.visible'):我通过添加 should('be.visible') 解决了这个问题:

cy.get('#reasonRecommendationByAgent')
  .should('be.visible')
  .type('Zdůvodnění doporučení zprostředkovatele')
  .should('have.value', 'Zdůvodnění doporučení zprostředkovatele')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM