Forum Discussion

marin's avatar
marin
Frequent Contributor
15 years ago

How to detect current browser language setting

Hello all,

how can  current browser language setting (not OS setting from Control Panel -> Regional Settings)  be retrived per script?



Thanks,



Marin

4 Replies

  • Hello,



    To retrieve the preferred language setting for the Firefox web browser, you can use the navigator.language property of the UIPage object (see the sample code snippet below).

    UIPage = Aliases.firefox.UIPage; 

    language = UIPage.navigator.language;




    As for Internet Explorer, you can retrieve its preferred language setting from the Windows registry. The setting is stored in the AcceptLanguage subkey of the HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\International registry key.


    To retrieve it from your TestComplete tests, you can use the following code:

     key = Storages.Registry("Software\\Microsoft\\Internet Explorer\\International", HKEY_CURRENT_USER); 

    language = key.GetOption("AcceptLanguage", "undefined");


    Let us know whether any of this helps.
  • marin's avatar
    marin
    Frequent Contributor
    Hello Alex,



    many thanks for your hint - it works perfectly for IE8.

    However, I can not make the Firefox snippet work for Firefox 6.0. Is FF 6.0 supported by Test Complete 8.5 at all?

    See attached screenshot how my object mapping looks like in FF 6.0 after recording a script.

    It seems as if objects inside the Firefox browser window (page, tables etc.) can not be selected at all when trying to map via e.g. Object Spy.



    Thanks,



    Marin
  • Hello, Marin


    TestComplete 8.50 does not support Firefox 6.0 (you can see a list of supported applications on the TestComplete system requirements page). That is why TestComplete cannot access Firefox 6.0 inner objects and that is why the code snippet does not work.

    Support for Firefox 6.0 is going to be included in the next TestComplete update.

  • marin's avatar
    marin
    Frequent Contributor
    Hello Julia,



    many thanks for the hint, I'll wait for the next TC version to continue testing with FF 6.0.



    Marin