Forum Discussion

jsc's avatar
jsc
Regular Contributor
13 years ago

automated multi-language test

Hi all,



my test currently takes around 2.5 hours to test the german (main) version of our software.

I now want to test the other versions of the software, namely english, french, maybe turkish versions as frequently language-related errors occur, that are not found by testing the german version.



A) First of all I thought of this solution:

- copying the complete project suite for each language

- adjusting the test for each language (screenshots, some on-screen actions)

- updating the test of the new languages every few months (leading test will be with the german language)



B) Now I thought about a maybe smarter solution:

1. keeping just one project suite

2.  make a language variable accessible in the test (already done)

3. adjusting the language specific on-screen actions (german: ...clickTab "Allgemein"; english: ... clickTab "General")

4. each region checkpoint checks a different picture depending on the selected language

5. updating the test every few months (leading test will be with the german language)



With 3. and 4. I do need help as I do not want to rush forward with a solution that will do the job but is roughly maintainable and hardly extendible (5.). I think 3. could be done by some variables / arrays but I am not sure about the screenshots. When using A) (copying complete project suite) I just can check the checkpoints and overwrite the stored picture as I do not have to care about a different name. When using B) I have to record the picture with a different name (maybe with ending "_EN" or "_TR").



Can anyone help me with that decision?



Thanks a lot, kind regards,



Joachim








4 Replies


  • Hi Joachim,





    You can map objects by language-independent properties (see the "Name Mapping" help topic for more information). For example, in MFC applications, you can use the ControlID property. Values of this property correspond to the objects' IDs defined in the resource.h file of an MFC application.





    Objects in .NET applications are recognized in TestComplete scripts by their native names, so it will be easier to create a localized script for a .NET application. Most likely, you will just need to change names of menu items, list box items, etc.





    To make your scripts language-independent, you can either create several Name Mapping configurations (one per each localized version of the application) or use the following approach:





    1. Record your test script with a "baseline" version of your application (for example, the English version). 





    2. Create an Excel file with localized names. For example:





    EnText1 EnText2 EnText3 ...

    FrText1 FrText2 FrText3 ...

    DeText1 DeText2 DeText3 ...

      ...             ...           ...





    3. In TestComplete, add the following lines at the beginning of your main script (outside any function):





    [JScript]





    var d = Sys.OleObject("Scripting.Dictionary");

    d.RemoveAll();





    This code will create a global Dictionary object which will store all localized window captions. Baseline captions will be used as keys. If your project contains several script units, you will need to use this object in all of them. Please see the "Calling Routines and Variables Declared in Another Unit" help topic to learn how to use objects declared in different units.





    4. Replace all WndCaption values in your scripts with appropriate values from the Dictionary object. For example, the following line:





    p.Window("MyWndClass", "My English window caption");





    should be replaced with:





    p.Window("MyWndClass", d.Item("My English window caption"));





    You can use the "Replace All" ("Edit | Find and Replace | Replace All") functionality to replace all strings automatically.





    5. Add a function that will read the localized captions from the Excel file to your main script. You can pass the required language as a parameter. Please see the "Using DDT Drivers" help topic to learn how to retrieve data from external storages (for example, Excel files) in TestComplete.





    To add a value to the Dictionary object, use the Dictionary.Add method. For example:





    d.Add("My English window caption", "My localized window caption");





    Please see the following MSDN Library article for more information on the Dictionary.Add method:

    http://msdn2.microsoft.com/en-us/library/5h92h863.aspx





    You can use the following sample script to initialize a global dictionary object with values read from an Excel file:





    [JScript]





    // MultilanguageSupport Unit





    var d; 





    function InitializeDictionary(languageName)

    {

      d = Sys.OleObject("Scripting.Dictionary");

      d.RemoveAll();

      var ddtDriver = DDT.ExcelDriver(Project.Path + "LanguageMapping.xls", "Sheet1", true);

      var languageColumnIndex = 0;

      for(languageColumnIndex = 0; languageColumnIndex < ddtDriver.ColumnCount; languageColumnIndex++) {

        if (languageName == ddtDriver.ColumnName(languageColumnIndex))

          break;

      }

      if (languageColumnIndex >= ddtDriver.ColumnCount) {

        Log.Error("The " + languageName + " language was not found");

        return false;

      }

      while(!ddtDriver.EOF()) {

        d.Add(ddtDriver.Value(0), ddtDriver.Value(languageColumnIndex));

        ddtDriver.Next();

      }

    }





    // Main Unit

    //USEUNIT MultilanguageSupport





    function Main()

    {

      InitializeDictionary("English");

      

      //.....

    }





    A sample Excel file is attached. Please note that the file must be located in your TestComplete project folder so the script can work correctly. If you want to save the file to another location, you will need to change the file path in the following line:

    var ddtDriver = DDT.ExcelDriver(Project.Path + "LanguageMapping.xls", "Sheet1", true);
  • jsc's avatar
    jsc
    Regular Contributor
    Hi Allen,



    thanks a lot. As I will improve my test-framework (after reading the article of Cem Kaner) and will start using data driven approaches, I will take your advices into account. I think, this will take a while, but I hope, it will pay back on the long run.



    Best regards,



    Joachim
  • joffre's avatar
    joffre
    Regular Contributor
    Sorry about ressurecting the topic, but I think it is useful for me too.



    I've created a topic with a similar problem.



    In my case, the default Windows language is English (but our software is in Portuguese). And I am having trouble on simple windows, as the example below, when I try to confirm that I want to end the system:



      Set BtnYes = Aliases.FPR_CLIENT.dlgFPWReportsCliente.btnYes

      Set BtnSim = Aliases.FPR_CLIENT.dlgFPWReportsCliente.btnSim

      If BtnYes.Exists Then

        BtnYes.ClickButton

      Else

        BtnSim.ClickButton

      End If




    The 'BtnYes' line is compatible with english Windows; the 'BtnSim' line is compatible with portuguese Windows.



    Can I use the same explanation to my problem? What do I need to do?



    The idea is to use the same ProjectSuite to both Windows languages (en_US and pt_BR).



    Thanks.

  • Hi Joffre,





    If there are no localized strings in your tests (e.g. localized parameters of the ClickItem method), you can simply create an additional Name Mapping configuration (see the "Name Mapping Configurations" help topic (http://support.smartbear.com/support/viewarticle/12446/) for more information). In this case, you'll be able to use a single alias for the two versions of the same button and will only need to switch between Name Mapping configurations when language is switched in the application.