Cypress - 无法在字段中输入

Dom*_*ála 9 javascript automated-tests cypress

我在自动测试中输入某个字段时遇到问题。\n我无法获取该字段,但我不知道为什么。

\n

这是我的代码:

\n
cy.get(\'#reasonRecommendationByAgent\')\n  .type(\'Zd\xc5\xafvodn\xc4\x9bn\xc3\xad doporu\xc4\x8den\xc3\xad zprost\xc5\x99edkovatele\', {force: true})\n  .should(\'have.value\', \'Zd\xc5\xafvodn\xc4\x9bn\xc3\xad doporu\xc4\x8den\xc3\xad zprost\xc5\x99edkovatele\')\n
Run Code Online (Sandbox Code Playgroud)\n

这是错误消息:

\n

在此输入图像描述

\n

有人有同样的问题吗?

\n

Opt*_*rks 12

click()尝试在键入之前添加:

\n
cy.get(\'#reasonRecommendationByAgent\')\n  .click()\n  .type(\'Zd\xc5\xafvodn\xc4\x9bn\xc3\xad doporu\xc4\x8den\xc3\xad zprost\xc5\x99edkovatele\', {force: true})\n  .should(\'have.value\', \'Zd\xc5\xafvodn\xc4\x9bn\xc3\xad doporu\xc4\x8den\xc3\xad zprost\xc5\x99edkovatele\')\n
Run Code Online (Sandbox Code Playgroud)\n


N..*_*N.. 7

我们遇到了类似的问题,我可以通过添加点击和聚焦来解决。我想,HELP DOCS文档也推荐了这个。

\n\n
\n
cy.get('#reasonRecommendationByAgent').click().focused()\n            .type('Zd\xc5\xafvodn\xc4\x9bn\xc3\xad doporu\xc4\x8den\xc3\xad zprost\xc5\x99edkovatele', {force: true})\n            .should('have.value', 'Zd\xc5\xafvodn\xc4\x9bn\xc3\xad doporu\xc4\x8den\xc3\xad zprost\xc5\x99edkovatele')\n
Run Code Online (Sandbox Code Playgroud)\n
\n