Forum Discussion

Lenina's avatar
Lenina
Occasional Contributor
15 years ago

How to feed TestCase1 response to TestCase2 request

Hi,

I have two test cases, executing TestCase1 returns a 'url' as response.
I need to extract a particular string from that url and give that string as input for TestCase2.

eg: Response is like: http://servername:8080/application/url/58

Now i need to extract last integer value '58' and store it in some property, pass this property as input into TestCase2 execution.

Searched in google, but didn't find anything useful.

Please help me if you know the way to do it.

Thanks,
Lenina

2 Replies

  • Hmmm... I'm not a guru in SoapUI but I try...

    1. Create a property on TestSuite level. Default value will be empty. The type is TEMPLATE. For example, its name is MyProperty1.
    2. Add the TearDown script on the TestCase1 which finds the necessary header, parses it (takes last number from the link, regExp can be used, for example) & stores it as value of property from step1.
    3. Add {/MyProperty1} to the link of resource used as source for TestCase2.

    I think it will work

    P.S. Some useful examples:
    context.currentStep.getHttpRequest().getResponse().properties["responseHeaders"]

    It's to find the necessary header.
    var userName = curTestStep.getProperty("MyProperty1").getValue();
    var userName = curTestStep.getProperty("MyProperty1").setValue();

    It's to manage the property value.
    Your object path will differ because your property location differs from those in example.
  • Lenina's avatar
    Lenina
    Occasional Contributor
    Hi Defender,

    Hey Thanks for your reply.

    I got few inputs from your reply. It is helpful.

    Thanks,
    Lenina