cancel
Showing results for 
Search instead for 
Did you mean: 

Detecting and changing current browser language setting in scripts in TestComplete

Sabiha
New Contributor

Detecting and changing current browser language setting in scripts in TestComplete

Hi, 

We are currently adding localisation support for our application.  I would like to create a suite of tests to test the localisation has been implemented correctly. Currently we have 3 suites of tests that run on Edge, Firefox and Chrome.

 

I would like to be able to detect and set the language  on on each browser before running my suite of tests. Is there a way to do this?

 

I have tried the following but this is returning the system locale, not the language set on the browser.

 

aqEnvironment.GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLOCALIZEDLANGUAGENAME)
aqEnvironment.GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLOCALIZEDDISPLAYNAME);
 

Any help much appreciated, thanks.

5 REPLIES 5
ebarbera
Staff

Re: Detecting and changing current browser language setting in scripts in TestComplete

Hi @Sabiha - 


How is it that you are currently detecting and setting the language at this time? This will help me understand how you may be able to do so in TestComplete. 

 

Also, here is a thread on some ways to check that information, maybe one of these methods could be integrated into a TestComplete script. 

 

https://stackoverflow.com/questions/673905/best-way-to-determine-users-locale-within-browser

 

Thanks, 

Emma

Sabiha
New Contributor

Re: Detecting and changing current browser language setting in scripts in TestComplete

Hi Emma,

I am not doing anything with the language settings currently, as I haven't needed to access them up until now. I am just trying to figure out the best way to do this in a script.

 

I have just tried the navigator.languages mentioned in the link but I am getting an error saying 'cannot read property 'language' of undefined'

 

My test scripts are written in Javascript, is there something additional I need to do to access the navigator.language property?

Marsha_R
Community Hero

Re: Detecting and changing current browser language setting in scripts in TestComplete

Here are some details about changing browser settings in scripts.  You'll see the note in there that Chrome security doesn't allow this kind of change, but it should at least work in Firefox.

 

https://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/changing-browse...

Sabiha
New Contributor

Re: Detecting and changing current browser language setting in scripts in TestComplete

Thanks Marsha,  

 

I have managed to get the languages on Firefox using the Preferences.intl.accept_languages

 

Does anyone know how I do the same on Chrome and Edge?

Marsha_R
Community Hero

Re: Detecting and changing current browser language setting in scripts in TestComplete

Looks like it is not possible with Chrome.  I'm not sure about Edge but they are closely related so it may not be possible with Edge either.

 

Marsha_R_1-1619714775472.png

 

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors