Forum Discussion

_Oliver_'s avatar
_Oliver_
Contributor
3 years ago
Solved

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...
  • ChrisAdams's avatar
    3 years ago

    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;