Character encoding issues in Eclipse for Java using Webdriver

天涯浪子 提交于 2019-12-20 03:21:12

问题


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


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!