Ask a Question

How to save spit values to one property

SOLVED
nick1
New Contributor

How to save spit values to one property

Hello,

 

please could someone help me with task below?

 

I would like to make data driven test where I use input excel file where i have colum Country in which can be one or more values separete with "," for this I would like to create groovy script in soapui which will parse this values and save it to property like

 

countriesProperty
<Country>UK</Contry>
<Contry>NL</Country>

 

in request will looks like

 

<CountryList>
${countriesProperty}
</CountryList>

 

Thank you in advance for any help.

7 REPLIES 7
richie
Community Hero

Hey @nick1 

 

why'd you need to use groovy for that?  It sounds pretty much standard fair - the embedded out the box functionality in ReadyAPI!/SoapUI Pro does exactly what you need.....or am I misunderstanding.

 

Are you saying you have a spreadsheet with a column and there are multiple comma separated values within one cell in the spreadsheet and you want to pick out the individual comma separated values?  I'm still struggling to see why groovy - you can manipulate the spreadsheet so that each field only has 1 value in it (save as .csv, manipulate, save back to .xslx or .csv or whatever)

 

Cheers,

 

richie

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
nick1
New Contributor

Hi Richie,

 

maybe I didn't explain my problem clearly. I have excel where every row mean different test case and in every test case have different count of Country (in request present like list). I could solve my problem with xml block in excel but users which define the data are not friends with it. I wanted to make it easier for them that they will fill out only country. In case will be define multiple countries then the user just separete it with comma.

 

I want to create script which will take country column and will create list for request

<Country>Country1</Country>

<Country>Country2</Country>

 

Is it clear now?

 

Thank you and have a good day

richie
Community Hero

Hey @nick1 

 

erm - I'm still a bit confused - are you saying you have a spreadsheet with country data like the pic below

Capture.PNG

 

 

and you need them in one column so you can run your data driven - so that you can loop the test, picking up the country value to populate your REST? SOAP? requests

 

Are you saying that different test cases will have different numbers of country values and so you want to use the datadriven functionality to populate the number of Country elements in your request based on the number of country values in your spreadsheet?

 

So using the example from the pic above:

For testcase1, A2 --> Afghanistan & Australia so you want your request to include the following:

<Countries>

<Country>Afghanistan</Country>

<Country>Australia</Country>

</Countries>

 

For testcase2, A3 --> Sweden, Ukraine, United Arab Emirates

so you want your request to include the following:

<Countries>

<Country>Sweden</Country>

<Country>Ukraine</Country>

<Country>United Arab Emirates</Country>

</Countries>

 

Is this what you mean?

 

Cheers,

 

richie

 

 

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
TanyaYatskovska
SmartBear Alumni (Retired)

Thanks for the help, @richie!

 

@nick1, is this what you were looking for?

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager



HimanshuTayal
Community Hero

Hi @nick1 ,

 

Didn't understand the query fully, but as i have understood it, you have some data in excel with comma(,) seperated and you want to spit it with , and store it in properties step write. So, for that you can use below piece of code and update or enhance as per your need.

 

def data = "data,data1" // you can fetch this data from particular cell
spiltData = data.split(",")
for(def i=0;i<spiltData.size();i++){
	testRunner.testCase.getTestStepByName("Properties").setPropertyValue("Prop"+i.toString(),spiltData[i])
}

Do let me know in case you need more help on this.

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal

@HimanshuTayal It's exactly what I wanted, thank you for help! Have a good day.

@nick1 

I am glad that it helped 🙂

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
cancel
Showing results for 
Search instead for 
Did you mean: