Selenium Web驱动程序中与德语角色(Ä ,,ö)相关的问题

发布于 2025-01-22 18:41:19 字数 284 浏览 2 评论 0原文

任何人都可以帮助我与这个问题有关:

我必须在硒中宣布文本,而当consol的irun中,我会遇到这种攻击失败的方法:

org.junit.comparessonfailure:tresect of Expect:< ] Mienrevant Markier>但是:

hier的问题在于德国的umlaut un,文本实际上是: Auto Als prämienRelevant

我该怎么做才能使此问题有效? br

Can anyone help my related to this problem:

I have to assert a text in Selenium, and when irun it from Consol, then i am getting that asserrtion is failed:

org.junit.ComparisonFailure: expected:<Auto als pr[ä]mienrelevant markier> but was:<Auto als pr[ä]mienrelevant>

The problem hier is with the german umlaut und the text appears actually is:
Auto als prämienrelevant

what should i do to make this asserrtion works?
BR

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉酒的小男人 2025-01-29 18:41:19

首先避免断言弦。取而代之的是在更结构性的类似CSS类或ID之类的内容上断言。这消除了问题。

如果您必须在文本上断言,那么您确实需要进入角色集的小精灵。基本上尝试并确保一切都使用UTF-8。在您的测试中,请查看您如何构建所断言的字符串。看起来umlaude a是其中一个字符串中的2个字节字符,并且在另一个字符串中具有更多字节(4)。尝试查看每个字符串的二进制表示形式。

First of all avoid asserting on strings. Instead assert on something more structural like a CSS class or ID. This removes the problem.

If you must assert on the text then you really need to get into the nitty gritty of character sets. Basically try and ensure that everything is using UTF-8. In your test look at how you are constructing the string you are asserting against. It looks like the umlauted a is a 2 byte character in one of the strings and has more bytes (4 perhaps) in the other string. Try looking at the binary representations of each string.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文