我必须使用 Cypress 验证网页上不同元素上的特殊字符串。
\n特殊字符串是:T!@$^()-_+, &_-=tt.\xc3\x98 {y}[a] \xc2\xa3 fi
每当我尝试验证字符串时,我都会在 Cypress 中收到以下断言错误:
\nAssertionError 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 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 })\nRun Code Online (Sandbox Code Playgroud)\n还附上了一个示例 HTML 页面:
\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 })\nRun Code Online (Sandbox Code Playgroud)\r\n