'Problem related to german Character (Ä,ö,ü) in Selenium Web Driver

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



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 diabolist