使用Webdriver的Eclipse中的字符编码问题 [英] Character encoding issues in Eclipse for Java using Webdriver

查看:176
本文介绍了使用Webdriver的Eclipse中的字符编码问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Eclipse与TestNG运行selenium webdriver与java。我正在使用Jexcelapi从OpenOffice(电子表格)导入数据,以便将我正在测试的网站上的字符串与电子表格中的值进行比较。我遇到的问题是我们有不同的地区,包括德国和北欧(瑞典,挪威和丹麦)。这些网站有字符串字符,带有特殊字符。这是在我的电子表格中正确复制,并在调试模式下运行脚本显示电子表格中的正确字符,但是当我得到我的结果,它会显示无效的字符,如?和空白。我已经看过这个论坛,在过去几天里搜到了各种各样的解决方案,但是似乎没有任何一种方法。我不知道问题是Eclipse,Jexcelapi还是OpenOffice。
我建议在某些地方将Eclipse中的编码设置更改为UTF-8,但仍然是同样的问题。我实例化了WorkbookSettings类并设置了编码,并使用了我的getWorkbook方法,我仍然会得到那些坏的字符,使我的脚本显示失败。

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?

提前感谢

推荐答案

我们有一个在远程机器上运行webdriver并尝试将文本粘贴到表单中时出现类似的问题。测试正在我们的开发机器上工作。
解决方案是设置环境变量

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

之后,使用正确的瑞典字符编码复制了webdriver。

After that the webdriver copied with the right encoding for swedish characters.

这篇关于使用Webdriver的Eclipse中的字符编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆