TestPlan Response Formats
Document

Response Formats

by Group Public on Thursday July 10 2008 @ 15:26:52 (1/1 Points)

Tutorial ↪User Guide ✑ Reply ✓ Stick It ✗ Ditch It ⚐ Tag It

The current response, for the current stage, is accessible via the %Response% object. This will always be exposed in a XML-like structure suitable for Xpath navigation. See below for specific types.

The "xpath" element of this map will be the result of the execution of that XPath against the current document. The type is not coerced by default, remaining in an indeterminate state, but following standard XPath conversion rules when requested. ''(see util.XPath.TypeEval)''

Document

Should you need the actual document object of the current response, you can use the %Response:/% dynamic item or the response function.

Types

text/html

Parsed/cleaned form exposed, this is based on a best effort parsing which may or may not be the exact same as the source.

Root element should be <html>

text/html (Selenium)

Same as text/html above, except that the result of the xpath is evaluated in the Selenium browser. It also has two limitations:

  • The result cannot be coerced into a node set (not supported yet).
  • Top-level functions other than count(xpath) are not supported

text/csv

Parsed and exposed in the form:

<document>
   <line>
      <COLUMN name='column name'>row-column-value</COLUMN>
      ...
   </line>
   ...
</document>

The COLUMN values are taken from the csv headers. If a column lacks a header, or there are no headers, a numbered name will be used. For the most part these will be exactly the same, in some odd cases the name may be mangled to be XML compliant -- in which case the name attribute can still be used to obtain the original form.

If you wish to access a specific line number using the XPath position syntax is sufficient, such as //line[4] to reference the 4th row of data (not counting a header line).

text/xml, application/xml

Parsed form exposed -- parsing errors will fail.

If you want to expose an email address of the following content:

<unsubscribe group-email="xxx@custX.com" group-id="1111" sysname="custX-norm" xmlns="http://webservices.ecircle-ag.com/ecm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <recipient timestamp="2007-10-11T07:00:07Z" user-id="1111111">
    <email>xxx@xxx.com</email>
    <mobilenumber xsi:nil="true"/>
  </recipient>
</unsubscribe>

you would use

%Response://soapecm:unsubscribe/soapecm:recipient/soapecm:email% %NewEmail%
Note: using the namespace {{soapecm:}} (the same as xmlns="http://webservices.ecircle-ag.com/ecm") is necessary in this place. Without the namespace it does't work. This a rather eCircle specific and we need a general solution sometime.

text/plain

Exposed in a <text>...</text> element, with the content of that element being the body of the response.

<text>...</text>

Email / MIME / HTTP

Email is exposed through the following format. Received HTTP MIME multipart requests are also exposed in this format (with the exception that <email> will be <http>).

<email|http>
    <headers>
        <HEADER name="HEADER">header_value</HEADER>
        ... <!-- for each header -->
    </headers>

    <!-- if HTTP -->
    <Status-Line ResponseCode='xxx'>...</Status-Line>
    <!-- end HTTP -->

    <content>string form of the body of the email</content> <!-- for non-multipart-->
    
    <content>  <!-- multi-parts will have several content children -->
        <headers>...</headers>
        <content>...</content>
    </content>
</email|http>

For example, if you wish to extract the message subject you would use:

%Response://headers/Subject/text()%

The HEADER values are taken from the email headers. For the most part these will be exactly the same, in some odd cases the name may be mangled to be XML compliant -- in which case the name attribute can still be used to obtain the original form.

application/json

JSON data types will be decoded into a simply form as follows.

<json>
  <MEMBER-Object name='MEMBER'>
     <MEMBER-Object>...</MEMBER-Object>
     <MEMBER-Array>
       <item index='0-based'>...</item>
       ...
     </MEMBER-Array>
     <MEMBER-Simple>...</MEMBER-Simple>
     <MEMBER-null null='true'/>
  </MEMBER-Object>
</json>

As with the HTTP/Email forms the names will be mangled as appropriate, with the name attribute having the original name.

The null attribute will only exist if the object is null and will be set to true.

RawGetURL

If you use a function like RawGetURL then you will not have access to the content directly, but rather the meta-information. It has a general structure like below.

<raw>
  <scheme>
    <!-- scheme specific part -->
  </scheme>
  <request>
    <!-- request details, may be limited or n/a -->
    <url>URL of the request</url>
  </request>
</raw>

The http scheme then follows the same format as in the section "Email / MIME / HTTP". However, the content section will not be included; this is to enable using the raw gets with arbitrary and large data types. The SetParsedResponse may nonetheless be used to promote the content to a document.

© 2008-2010 edA-qa mort-ora-y
Using Persephone and TestPlan
Tag: