cancel
Showing results for 
Search instead for 
Did you mean: 

How to add some number in data

SOLVED
Highlighted
New Contributor

How to add some number in data

Hi! I have TestCase, where in one requset i get data (some number), and this data i must insert in another soap request, but with plus(+) one (1). I write ${path to data...+1} but it isn`t work. How can i do that?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: How to add some number in data

Hi,

 

Take the following example. I have a request where the response would contain a x = 1:

 

2019-06-03_11h31_47.png

I am extracting this value into a test case property:

2019-06-03_11h33_40.png

An then I am sending it as a parameter while also incrementing its value by 1:

2019-06-03_11h34_46.png

 

Here's how the expression works:

// this is a way to tell ReadyApi that what will be inside { ... } will be a groovy script
${=...} 

// reading the test case property named 'x'
context.expand('${#TestCase#x}')

// the properties are always strings in ReadyApi, so we need to parse the value to int
context.expand(...).toInteger()

// and finally increment by 1
...+ 1


 



If my answer helped please click on the 'Accept as Solution' button.

View solution in original post

5 REPLIES 5
Highlighted
Community Hero

Re: How to add some number in data

Hi,

 

Take the following example. I have a request where the response would contain a x = 1:

 

2019-06-03_11h31_47.png

I am extracting this value into a test case property:

2019-06-03_11h33_40.png

An then I am sending it as a parameter while also incrementing its value by 1:

2019-06-03_11h34_46.png

 

Here's how the expression works:

// this is a way to tell ReadyApi that what will be inside { ... } will be a groovy script
${=...} 

// reading the test case property named 'x'
context.expand('${#TestCase#x}')

// the properties are always strings in ReadyApi, so we need to parse the value to int
context.expand(...).toInteger()

// and finally increment by 1
...+ 1


 



If my answer helped please click on the 'Accept as Solution' button.

View solution in original post

Highlighted
New Contributor

Re: How to add some number in data

Is it nessesary using http get data? Because i using get data, then i choose my previous request(${Show limit#Response#declare namespace out='http://IntegrationService'; //out:response[1]/serviceResponse[1]/card[1]/cardLimit[1]/cardPosLimit[1]}) and if i add, in the end +1, it isn`t working

Highlighted
Community Hero

Re: How to add some number in data

Well... I don't know if you can do it directly. But extracting the data in a different step as shown in my previous reply should make the test cleaner so I would advise you to do so.



If my answer helped please click on the 'Accept as Solution' button.
Community Hero

Re: How to add some number in data

HI @PavloRaketa 

 

Oh - is this related to your other post on the forum?

 

you just want to concatenate a '+' symbol before the parameterised value - correct?

 

Capture.PNG

 

Can you see my 'Authorization' query parameter in the screenshot above?

I would just add a '+' symbol in front of the parameter value.

 

So currently the value specified is as follows:

${#[Generate Access Token#Generate Access Token#Properties 1]#access_token}

I would just add a plus symbol in here so it reads

 

+${#[Generate Access Token#Generate Access Token#Properties 1]#access_token}

 

Does this help?  If not - if you could provide a bit more info - that would help us

 

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
Highlighted
Community Hero

Re: How to add some number in data

test post - post added AFTER my last 

 

NOTE to everyone.  please ignore this post - I'm not seeing the latest additions to posts so I'm just trying to work out whats going on - Lucian hadn't responded to this at all before I'd added my post - as soon as I respond I then saw Lucian's

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
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors