Forum Discussion

mkhan031486's avatar
mkhan031486
Contributor
7 years ago
Solved

How to add text with a property transfer

Hi have a test suite which has two test cases. First test case has a payment request that has a Account No for example, 2356698. The second request that I have is about creating a Autopay (recurring) Profile for the customer. In the request one of the elements is accountID with letters on it for example 2356698REC.

 

Is there any way, I can do a property transfer and add those three letters REC. Considering I have to perform the test multiple times so the accountID will change everytime. So I would like take the accountID from first request and transfer it to the second request but also want to add REC to it. 

 

Is that possible through a property transfer or groovy script? Any kind of help will be appreciated. 

  • You do not have a separate test step for that i.e., neither property transfer nor groovy script test step.

     

    Instead add a script assertion step to the First request and extract the account Id and store it at test case level custom property

     

    Hope you know how extract the accountId from your response. If not, please provide the response.

     

    In the same script assertion, once account Id is extracted use below statement to store value at test case level custom property

    //Assign the extracted value to below variable; for now using dummy value

    def accountId = '12345'

    context.testCase.setPropertyValue('ACCOUNT_ID', accountId)

     

     

    In the second request, just below to 

     

    <accountId>${#TestCase#ACCOUNT_ID}REC</accountId>

5 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    You do not have a separate test step for that i.e., neither property transfer nor groovy script test step.

     

    Instead add a script assertion step to the First request and extract the account Id and store it at test case level custom property

     

    Hope you know how extract the accountId from your response. If not, please provide the response.

     

    In the same script assertion, once account Id is extracted use below statement to store value at test case level custom property

    //Assign the extracted value to below variable; for now using dummy value

    def accountId = '12345'

    context.testCase.setPropertyValue('ACCOUNT_ID', accountId)

     

     

    In the second request, just below to 

     

    <accountId>${#TestCase#ACCOUNT_ID}REC</accountId>