18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Is there any way to get the locale of the browser?
I am writing the tests for an international application. I am using Java and I have also write the code to get international strings based on a predefined locale string (e.g. 'zh_CN') in my configuration file. I am wondering if there is a better way of getting this location information from Sahi API (e.g. browser.getLocale())? If so, my tests could determine the languages based on the browser language setting at the runtime. I didn't find it in the current implementation. Did I miss anything? Is there any workaround if this is not implemented? Thanks.
Comments
Direct answer: You may use the navigator.language on Firefox and navigator.userLanguage on IE to get the browser language.
However, this may not be useful to you. During automation, one would want to perform the tests with different languages from the same browser. If we were to depend on the browser locale, you would end up running the scripts with the same language. It is better to pass it in externally to force the browser to test the application in various languages.
Regards,
Narayan