Ask a Question

Soapui project:. get any specific cell value of Data source grid

SOLVED
Raju506315
Occasional Contributor

Soapui project:. get any specific cell value of Data source grid

Soap ui project have one datasource for following data

Column properties are
Emp number , Emp salary, Emp Location Data is following way for above columns.
1 5000 USA
2 4000 INDIA
3 3000 Canada
......
.......
Now I want print or log or store value of 2 nd employee salary i.e 4000 ... That means I want to get any specific cell value from data source cell value.. using groovy...
5 REPLIES 5
richie
Community Hero

Hi @Raju506315 

 

Can you describe your use case a little more please?

 

The reason I ask is that the way I read what you've described it appears to suggest that you want to extract the values of your grid datasource 2nd column without actually using the values first - which doesn't appear to be logical - you've got those values already in the spreadsheet - why would you need to save them elsewhere without using them?

 

Also I'm not understanding why you think you need to use groovy to do this - the OTB (out the box) functionality supports extracting values already...???

 

you're using a grid datasource, not an excel datasource - what mechanism are you using the populate the grid datasource.....is the grid populated via the results of a GET or POST or something else?

 

The more detailed info you supply, the more effectively people can help you with your queries,

 

thanks,

 

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
Raju506315
Occasional Contributor

HI Richie,
1)My intention is validate my response with data source value..
2) I am using datsource and loop passing data...
3) please look at following one more example
Data source is having 4columns names and followed by given data
Location,Group1Salary,Group2salary,Grouop3salary
Data for above columns
USA 100 200 300
INDIA 250 350 400
Uk 100 200 300
It means
Location=USa then Group1Salary salary 100 , Group 2 salary=200 , Group 3salary=300.
Similar way remaining country salary I define in datsource..
For every loop I am sending location and Group info.. Then API give salary based on country and group...
So I want validate response value with datsource value.. Thanks ...
Raju506315
Occasional Contributor

Example
Data source having following columns
Country name , Group1,Group,2, Group3
Data as follows

USA 600 700 800
INDIA 500 600 900
Uk 400 599 600
..
.......
In my loop request I am sending country name and Group ..then ApI will give slary based on given inputs...
ASo I want validate response salary is expected or not based on data source ... And validating .. Thanks ..

Hey @Raju506315 

 

Ok - so to be cleaar - your datasource has 4 columns Location, Group1Salary, Group2alary, Group2Salary

 

you are submitting a request that contains "Location" and "Group Info" - how are you passing these?  Is it a GET so the attributes you submit are part of the query filter or is it a POST when you are submitting a payload along with these attributes?

 

If I'm understanding you - you don't need to use groovy to verify the returned data is the same as in  your datasource - you can use the OTB 'Select Content' function in your json? xml? content match assertion.

 

1. If you create the assertion on the relevant attribute in the response via the 'Outline' tab,
2. hit 'Select Content',
3. select the testsuite that contains your test,
4. then select the test,
5. then select the GET or POST request you are verifying the content within,
6. then select 'Property [Request]' - this launches a 'Select JSON' window (or 'Select XML' if the response is XML), 7. then select the attribute that contains the relevant value - e.g. 'Salary' and hit 'OK' - this will close the form and generate a string in your 'JSONPath Match Assertion' something like the following:

If its a GET request and your submitting the Salary as a template parameter - the dynamically generated value is something like 

${TestStepName#TemplateParameterNameValue}

If its a GET with say a template/URI parameter value that is submitted - the assertion content is something like ${REST Request#Salary} - this would be via a GET as follows:

GET --> /awks/eek/whatevs/Something/GetSalaryDetails/{Salary} 

If it's a POST it's a bit more complicated (cos you're picking out attribute values from the payload rather than from a query parameter in your REST request - it's something like:

${TestStepName#Request#$['attribute in request that contains the value']}

So the above approach allows you to successfully assert against the submitted values to ensure they are correct in the response.

 

You can use the same approach via the 'Select Content' to match values in other test steps - not just REST or SOAP requests.

 

Does that help?

 

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
Raju506315
Occasional Contributor

Sorry It's not working ..

I want read in this format for my case

 

Example

 

Country Group1Salary Group2Salary Group3Salary
USA  100 200 300
INDIA 250 350 400
Uk 280 370 460

def grSalaryone = context.expand( '${DataSource#Group1Salary#}' )
def grSalarytwo = context.expand( '${DataSource#Group2Salary#}' )

Now i want print/Log Group1Salary  of india i.e  250 column 2nd row value .NOT all groups values .

Expected selected group country value only needs to print or set to allreday defined  propertvalue

Simular way i need to print only select group and contry values only

 

cancel
Showing results for 
Search instead for 
Did you mean: