Passing an array element in the "value" field of a test step
Hi all,
I need to call a service with a parameter value that should be an array.
The parameter name is officialLanguages and I need the generated URL to look like that
xxxxxxxxxx?officialLanguages=EN&officialLanguages=FR
I cannot figure out how to put these two elements in the value field of the test step. For example, this (see below image) does not work because the whole ["FR","EN"] is considered as one single string and not as an array of two strings.
I tried various combination with and without quotes, with and without brackets etc... but nothing worked.
I found a workaround by disabling URL encoding for this parameter value and by defining the value as shown here :
But that looks to me like an unorthodox solution...
Is there an easier/cleaner way to do that ?
Regards
Oliver
I'm not sure about a cleaner way in that screen, but another method would be to use a Groovy script step prior to the service call test step which builds the URL based on the array..
E.g.
def rootUrl = "Whttps://www.yyyyy.com/"; def languageArray = ["FR","EN","US"]; def newUrl = rootUrl; // Iterate over the language array to add each language. // Note, this is purely an example and needs more work to include the ? and & // as appropriate. languageArray.each{val -> newUrl = newUrl + "officialLanguages=" + val; } // Setting the next test step Endpoint to be the 'newUrl'.... testRunner.testCase.testSteps["myServiceRequest"].properties['Endpoint'].value = newUrl;