Forum Discussion

otori's avatar
otori
New Contributor
3 years ago
Solved

Multilanguage Keyword Tests

Hello,

 

Our Program under Test can be used with different languages.

We would like to make our Keyword-Tests work independently of the selected languages.

 

For the object detection I read about using multiple configurations of the Name-Mapping.

However, often tests perform operations like ClickItem, CheckItem and SelectTab, where the item name is passed as a value.

 

I could not find a solution how to make these operations language-independent.

I read, that the methods also accept Regular Expressions, however, I can only set a constant (string), or a code expression, not directly a regex.

I could not find a way to return a regex with the single line code expression. ("import re; re.compile(...)" cannot be done (I am using python here))

As an alternative I thought about a script that has functions returning the correct localized captions. But also I could not find a way to call a script function from the "code expression"-dialog.

 

Do you have any idea, how I can do one of the two options described (use a regex or call a script function)?

Or do you have another solution proposal on how to make the keyword tests be language independent?

 

Best regards.

  • otori's avatar
    otori
    3 years ago

    Hello Marsha,

     

    sorry for my delayed reply.

    I already found this webpage before creating this forum thread and it was the base of my actions.

     

    First, it describes how 'Name Mapping' can be approached in a multi language program. This can also be done for my keyword tests.

    Second however, it is described how to use regular expressions for operations like 'ClickItem' (Where the value parameter is the caption of the Item).

    The example works for Script-Tests, but I could not figure out how to do this for KeywordTests. (See the attached image, where I can enter either a constant string, or a code expression, however I could not create a regex there.)

     

    My solution now is to create a ProjectSuite variable that stores the language. Then I use the following code expression to select the correct caption:

    "'german caption' if ProjectSuite.Variables.ProgLang == 'de' else ''english caption"

     

     

2 Replies

    • otori's avatar
      otori
      New Contributor

      Hello Marsha,

       

      sorry for my delayed reply.

      I already found this webpage before creating this forum thread and it was the base of my actions.

       

      First, it describes how 'Name Mapping' can be approached in a multi language program. This can also be done for my keyword tests.

      Second however, it is described how to use regular expressions for operations like 'ClickItem' (Where the value parameter is the caption of the Item).

      The example works for Script-Tests, but I could not figure out how to do this for KeywordTests. (See the attached image, where I can enter either a constant string, or a code expression, however I could not create a regex there.)

       

      My solution now is to create a ProjectSuite variable that stores the language. Then I use the following code expression to select the correct caption:

      "'german caption' if ProjectSuite.Variables.ProgLang == 'de' else ''english caption"