Forum Discussion

gjmaster018's avatar
gjmaster018
New Contributor
6 years ago

Adding a dictionary object to a variable on keyword tests

Has anyone tried setting a variable in a keyword test with a value consisting of a dictionary object (a key value pair) ?   IT can be done on scripts but i never made it worked on KeywordTests   ...
  • hkim5's avatar
    6 years ago

    Set Variable Value operation can allow you to create dictionary variables inside of TestComplete.

    Then using a run code snippet, you can access the key-value pairs inside of the dictionary variable. 

    in the screenshots below, I have a dictionary type variable called dict1 with key value pairs key1:value1 and key2:value2. for the sake of simplicity, I have called the value1 using dict1['key1'] and printed the corresponding value with a log message while using run code snippet.

    similarly, i used the log operation of the keyword test, and used the value of "code" with the corresponding dictionary syntax (i.e.:  keywordtests.dictionary1.variables.dict1['key2']) and it printed the corresponding value of the second key value pair. 

    it is important to note that no matter what you do, even with a keyword test, you will need to call on the proper key value pair using the correct syntax if you are parameterizing these values into your operation.