小编Tau*_*ikh的帖子

无法验证 Cypress 中的特殊字符串

我必须使用 Cypress 验证网页上不同元素上的特殊字符串。

\n

特殊字符串是:T!@$^()-_+, &_-=tt.\xc3\x98 {y}[a] \xc2\xa3 fi

\n

每当我尝试验证字符串时,我都会在 Cypress 中收到以下断言错误:

\n

AssertionError Timed out retrying after 4000ms: Expected to find content: \'T!@$^()-+, &-=tt.\xc3\x98 {y}[a] \xc2\xa3 fi\' within the element: <label> but never did.

\n

以下是屏幕截图:\n在此输入图像描述

\n

下面是代码块:

\n
    cy.visit(\'public/special-character.html\')\n    \n    cy.get(\'label\').contains(\'T!@$^()-_+, &_-=tt.\xc3\x98 {y}[a] \xc2\xa3 fi\');\n    cy.get(\'p\').contains(\'T!@$^()-_+, &_-=tt.\xc3\x98 {y}[a] \xc2\xa3 fi\');\n   \n  })\n
Run Code Online (Sandbox Code Playgroud)\n

还附上了一个示例 HTML 页面:

\n

\r\n
\r\n
    cy.visit(\'public/special-character.html\')\n    \n    cy.get(\'label\').contains(\'T!@$^()-_+, &_-=tt.\xc3\x98 {y}[a] \xc2\xa3 fi\');\n    cy.get(\'p\').contains(\'T!@$^()-_+, &_-=tt.\xc3\x98 {y}[a] \xc2\xa3 fi\');\n   \n  })\n
Run Code Online (Sandbox Code Playgroud)\r\n
\r\n
\r\n …

javascript contains cypress

0
推荐指数
1
解决办法
705
查看次数

标签 统计

contains ×1

cypress ×1

javascript ×1