I have a requirement where I am trying to automate the registration form which is in French language, while automating I am trying to get the text of the error messages which are in French(localised) language.
Example code snippet:
String text=driver.getText(By.cssSelector("#first_name + label.error"));//which gets the localised error message string
When I print the text some junk characters are getting printed. Actual output which is printed:
Seulement alphabets, des chiffres et des espaces sont autorisï¿½
Seulement Alphabets, des chiffres et des espaces sont autorisés
I am trying to
assertEquals(actualoutput,expectedoutput) which is getting failed
I am getting the expected output from the
language.properties file where translated text is there(which is UTF-8 converted and loaded as properties file).
I have even tried to convert the actual output to UTF-8 with the below code
byte ptext = text.getBytes("ISO-8859-1"); actualMessage=new String(ptext,"UTF-8");
But still it is not working getting printed with the junk characters as mentioned above. (
Seulement alphabets, des chiffres et des espaces sont autorisï¿½)
Does the getText() gets the text in UTF-8 converted?
Please let me know your thoughts on this and help me.