Before integrating our tests on CI servers, I made some tests with different sets of locale settings. Unfortunately, the ui.enterText(...) function doesn't work correctly depending on the keyboards and languages settings.
1- When I run tests with US keyboard and English(Canada) language, everything works correctly.
2- When I run tests with Canadian french keyboard and English(Canada) language, the enterText function outputs wrong characters when characters are non alpha-numeric...
I tried two solutions without success:
a) The solution proposed by "3061" in the "Problem with enterText() and WT.setLocaleToCurrent" topic
- Code: Select all
private void enterTextWithDefaultLocal(String s)
{
WT.setLocaleToCurrent();
ui.enterText(s); // enter the text in the ui
WT.resetLocale();
}
This solution doesn't make any change when I run tests.
b) The solution proposed by "3061" in the "Question mark ? in enterText" topic.
- Code: Select all
/**
* Use this if ui.enterText(String s) does not enter some chars correctly.
*
* @param s
* The text to be entered
* @param language
* examples: "en" for English, "de" for German
* @param country
* examples: "US" for USA, "DE" for Germany
*/
private void enterTextWithTempLocale(String s, String language, String country)
{
Locale defaultLocale = Locale.getDefault(); // remember previous Locale
Locale.setDefault(new Locale(language, country));
WT.setLocaleToCurrent();
ui.enterText(s); // enter the text in the ui
Locale.setDefault(defaultLocale); // reset to previous locale
WT.setLocaleToCurrent();
}
This solution doesn't work well because each machines that will start the tests have different configurations, so I need to automatically detect which language and country is currently used by the machine.
It is possible to set this settings automatically based on the machine configuration?
Any suggestions?
OS: Winows XP Pro SP3 in English, always with newest updates
Java: version jdk1.6.0_12
WindowTester: WindowTester SWT professional version 3.8.0.200904021341 for Eclipse 3.4
Eclipse: Version: 3.4.0 Build id: I20080617-2000