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
I tried using
Set Variable varObj and then use code expression to put a value of
{key1:value1,key2:value2}
but testcomplete says its not a valid expression.
I need to put a dictionary object on the keyword test because i will be calling a method/function that accepts a dictionary as a parameter. This object contains a key value pair of headers and header values for use in sending an http requests.
Any leads on how i can achived this?
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.