Skip to main content
Format text
Source Link
Kate Paulk
  • 31.5k
  • 8
  • 55
  • 109

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� Expected

Seulement alphabets, des chiffres et des espaces sont autoris�

Expected output: Seulement Alphabets, des chiffres et des espaces sont autorisés ISeulement Alphabets, des chiffres et des espaces sont autorisés

I am trying to assertEquals(actualoutput,expectedoutput) which is getting failed I

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

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�)Seulement alphabets, des chiffres et des espaces sont autoris�) Does the getText() gets the text in UTF-8 converetdconverted?

Please let me know your thoughts on this and help me.

Thanks Sairkishna

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� Expected output: 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 converetd?

Please let me know your thoughts on this and help me.

Thanks Sairkishna

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�

Expected output: 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.

Thanks Sairkishna

I have a requirement where iamI am trying to automate the registration form which is in French language, while automating iamI am trying to get the text of the error messages which are in French(localised) language.

exampleExample code snippet: String text=driver.getText(By.cssSelector("#first_name + label.error"));//which gets the localised error message string when i

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. actualActual output which is printed  : Seulement alphabets, des chiffres et des espaces sont autoris� expectedExpected output  :Seulement Seulement Alphabets, des chiffres et des espaces sont autorisés IamI am trying to assertEquals(actualoutput,expectedoutput)assertEquals(actualoutput,expectedoutput) which is getting failed IamI am getting the expectedoutputexpected output from the language.propertieslanguage.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");

byte ptext[] = text.getBytes("ISO-8859-1");
actualMessage=new String(ptext,"UTF-8");

butBut 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 converetd?

pleasePlease let me know your thoughts on this and help me.

Thanks Sairkishna

I have a requirement where iam trying to automate the registration form which is in French language, while automating iam 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� expected output  :Seulement Alphabets, des chiffres et des espaces sont autorisés Iam trying to assertEquals(actualoutput,expectedoutput) which is getting failed Iam getting the expectedoutput 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 converetd?

please let me know your thoughts on this and help me.

Thanks Sairkishna

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� Expected output: 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 converetd?

Please let me know your thoughts on this and help me.

Thanks Sairkishna

Source Link
saikrishna
  • 654
  • 3
  • 9
  • 18

latin characters getting displayed as junk characters from the webdriver getText() command

I have a requirement where iam trying to automate the registration form which is in French language, while automating iam 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� expected output :Seulement Alphabets, des chiffres et des espaces sont autorisés Iam trying to assertEquals(actualoutput,expectedoutput) which is getting failed Iam getting the expectedoutput 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 converetd?

please let me know your thoughts on this and help me.

Thanks Sairkishna