Forum Discussion

Beice's avatar
Beice
Occasional Contributor
15 years ago

Can "Property Transfer" function support non-xml context ?

Hi

Since it use X-Path to fetch the property value . I want to know whether the it can support non-xml content .

here is the example , we have a http response , and I want to extract the number 1234 in the body and put into a property for next http request .

HTTP/1.1 200 OK
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 5
Content-Language: en-US
Date: Thu, 09 Dec 2010 07:03:50 GMT
Server: WebSphere Application Server/6.1

Application_1234

4 Replies

  • Hi!

    sorry, it can't, but this can easily be done with a groovy script instead.

    Regards!

    /Ole
    eviware.com
  • Slimy37's avatar
    Slimy37
    Occasional Contributor
    Hi, sorry for jumping on to this thread, but I'm in a similar position and being a newbie I'm struggling with the basics. I understand how to get the value using Groovy script, but how do I get the actual response in the first place? In other words, I'm after the Groovy code that would take the response message from a test step and put it into a variable that I can then manipulate to get the relevant part.

    I guess as an extension to this I'm also interested in the code required to pass a variable back into the request message of a test step.

    Any help would be greatly appreciated, thanks.
  • flalar's avatar
    flalar
    New Contributor
    We have the same issue. We've used some xpath to get ahold of a response value. We are now trying to insert this value into a json request using this type of syntax ${#TestCase#QuoteId} Where the "QuoteId" is the name of the xml element in the response. However it does not seem to be working. Does the "TestCase" part also need to match the name of our testcase? And do we first need to set the "QuoteId" value from the response into a defined property?

    Cheers
  • Slimy37's avatar
    Slimy37
    Occasional Contributor
    I've progressed a bit since this morning. Here is the Groovy code that I was given to transfer a value back into a test step;

    def targetstep = testRunner.testCase.getTestStepByName("Test step");
    def targetCase = targetstep.getTestCase();
    targetCase.setPropertyValue("propname", "propval");//This is the value you want put into the request.

    Within the test step, I have a request as this;

    a=2&b=help+me&state=${#TestCase#propname}&return=nothing

    From what I understand the '#TestCase#' is how it gets the details from a test case, in my case the test case is called targetCase. It's not actually the name of the test case, which is where I was getting confused before.

    However, for some reason this doesn't work all the time, and I don't know why. I sent the XML project over to a friend to look at, he made the changes above and told me what he did. I made the same changes and it didn't work. He then sent the XML project back to me, and it worked fine. I can only assume that something else is involved that he has done without realising.