galenframework / galen

Layout and functional testing framework for websites
http://galenframework.com
1.41k stars 163 forks source link

Encoding problem in element locator on Windows #472

Open IrekW opened 7 years ago

IrekW commented 7 years ago

Hi! I have a test (regPage.test.js) scenario that uses page declared in "pages/regPage.js". The page extends the standard GalenPages. One of it's functions uses this code: var name = "Besetzungsgröße"; var locator = "xpath: //span[text()='" + name + "']/../div";

Then the page is loaded in test file using load("pages/regPage.js") and the function is called.

The problem is that when the test runs, it can't find the element. Console log says:

org.mozilla.javascript.JavaScriptException: Error: No such element: xpath //span[text()='BesetzungsgrĂ?Ăźe']/../div[1] (<cmd>#340)

All files are encoded as UTF-8 without BOM and I can see them correctly in different editors. If I modify the file's encoding and switch it to ANSI, the element is located correctly and test runs without problems. But when I restore the default encoding (UTF-8 without BOM), the test breaks. I tried to add the BOM header to the file but then Galen complains about unknown character in the file. I also tried the options with adding the encoding to the run options of Galen (-Dfile.encoding=UTF-8) or setting the JAVA_TOOLS_OPTIONS=-Dfile.encoding="UTF-8" but unfortunately still without success.

Is there some other option I could use? Unfortunately, I can locate this element only by text, not id.

cyildirim commented 7 years ago

I tested your case in macos, it worked for me. Did you try other encoding options for windows (ex: -Dfile.encoding=iso-8859-1) ?

IrekW commented 7 years ago

I also saw it working on MacOS and on Linux, the problem occurs only on Windows. I also tried other encodings (ISO-8859-*, ASCII, Windows encodings)- it always looked as if it was ignored.