Forum Discussion

wyderp's avatar
wyderp
New Contributor
16 years ago

Filling in request values with groovy

Can someone provide a code snippet that will read data from a file (key=value) and insert values into a request node i.e, "Login" and run the request X number of times?

for example:
dataFile.txt
username=Login0
password=Soap0
username=Login1
password=Soap1
username=Login2
password=Soap2
username=Login3
password=Soap3
...

request:

 

 
     
        ?
        ?
     

 


then, loop through request with values in file:
Iteration 1:

 

 
     
        Login0
        Soap0
     

 


Iteration 2:

 

 
     
        Login1
        Soap1
     

 


etc...

Thanks!

3 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello!

    You should have a look at the DataSource functionality of soapUI PRO, which would help you achieve what you're after. Also, this page from the user guide may help you. Good luck!

    Regards,
    Dain
    eviware support
  • wyderp's avatar
    wyderp
    New Contributor
    Thanks for the tip but we can't use SoapuuPro so I need more information on coding what I need to accomplish.  Is there a way to iterate over the values in a flat file and populate a request with each set of new values?
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi wyderp,


    You can write a Groovy script to load values from a file and assing property values using context object and setProperty.

    This is the crux of the solution. The rest you should be able to find online rather easy.
    I hope this helps.


    Cheers!
    /Nenad Nikolic a.k.a. Shonzilla