I am using spanish UTF-8 characters in my WebDriver test which works ok if ran from Eclipse, but if I try to run the same via Ant the test fails as it cannot find some elements with special characters. I figured out the encoding is messed up but I cannot seem to set up it properly. I tried the following to no avail
<junit printsummary="yes" haltonfailure="no" fork="yes">
<jvmarg value="-Dfile.encoding=UTF-8"/>
<classpath>
<pathelement location="${bin}" />
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</classpath>
<test name="com.yourcompany.selenium.MyTest" haltonfailure="no" todir="${report}/xml" outfile="TEST-result">
<formatter type="xml" />
</test>
</junit>
Tried also by adding the encoding value to command line, but the test still fails.
Found the culprit. The encoding was handled correctly by the junit task, the problem was at the compiling level as Ant seemed to compile using Cp1250 encoding. Adding encoding=”UTF-8″ to the compile task solved the problem.