Forum Discussion

PavloRaketa's avatar
PavloRaketa
New Contributor
5 years ago
Solved

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?

  • Hi,

     

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

     

    I am extracting this value into a test case property:

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

     

    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
    
    
    

     

5 Replies

  • richie's avatar
    richie
    Community Hero

    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?

     

     

    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

     

     

    • richie's avatar
      richie
      Community Hero

      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

  • Lucian's avatar
    Lucian
    Community Hero

    Hi,

     

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

     

    I am extracting this value into a test case property:

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

     

    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
    
    
    

     

    • PavloRaketa's avatar
      PavloRaketa
      New Contributor

      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

      • Lucian's avatar
        Lucian
        Community Hero

        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.