I'm currently using Eclipse with TestNG running selenium webdriver with java. I am using Jexcelapi to import data from OpenOffice (spreadsheet) to compare strings on the website i'm testing with values in the spreadsheet. The problem I have is that we have different regions including germany and Nordics (Sweden, Norway and Denmark). These sites have string characters with accents special characters. This is copied correctly on my spreadsheet and running the scripts in debug mode shows the correct character from the spreadsheet but when i get my results, it displays invalid characters such as ? and whitespace. I have looked through the forum and searched everywhere for the past few days and seen various solutions but none seemed to work. I'm not sure if the problem is with Eclipse, Jexcelapi or OpenOffice. I changed the encoding settings in Eclipse to UTF-8 as advised in some places but still the same problem. I instantiated the class 'WorkbookSettings' and set the encoding and used it with my getWorkbook method and I still get those bad characters that make my scripts show failures.
Can anyone help with this please?
Thanks in advance
We had a similar problem when running webdriver on a remote machine and trying to paste text into forms. The tests were working on our development machines. The solution was setting the environment variable
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF8
After that the webdriver copied with the right encoding for swedish characters.
来源:https://stackoverflow.com/questions/9787862/character-encoding-issues-in-eclipse-for-java-using-webdriver