Forum Discussion

Christian_Eiche's avatar
Christian_Eiche
Occasional Contributor
13 years ago

how to do an assertion on XML Start Tag of xml file

1. I am using a http request get method and getting back from our server a xml file
2. Http Response is an xml looking in viewer with raw-tab like this:

<?xml version="1.0" encoding="windows-1252"?>
<!-- This XML-document is generated by PowerParts.
It's well-formed and valid against genius_part.xsd XML Schema Definition. -->
<genius_part branch_id="" unit_type="imperial" language="GB">
<format_description major_version_number="1" minor_version_number="1" />
<geometry_2d>
<line layer="1" layer_class="0" line_style="Continuous" color_type="102" line_width="-1" rgb="0">
<start_point x="0.00000000000000" y="0.00000000000000" z="0.00000000000000"/>
<end_point x="8.00000000000000" y="0.00000000000000" z="0.00000000000000"/>
</line>
3. how is it possible to check/validate the following line of xml: <?xml version="1.0" encoding="windows-1252"?>
because I have to check if encoding is set to correct codepage of selected language.
If I try assertion <contains> does not work. Contains only works on "visible" content which I can see if I switch to view xml-tab.

Any suggestions how to solve this?

Thank's

Peter

7 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Peter

    Try adding a "Simple Contains" assertion to the teststep and specifying the entire first row as the token - does that work?

    regards!

    /Ole
    SmartBear Software
  • Christian_Eiche's avatar
    Christian_Eiche
    Occasional Contributor
    Hi Ole,
    unfortunatelly it does not work. And I will get following error msg:
    ->Missing token [<?xml version="1.0" encoding="windows-1252"?>] in Response

    Any other ideas?

    Thank's Peter
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    wow - that sounds strange - doesn't the response contain this token? Could you send a screenshot of the Raw message tab for the response message?

    thanks in advance,

    regards,

    /Ole
    SmartBear Software
  • Christian_Eiche's avatar
    Christian_Eiche
    Occasional Contributor
    Hello Ole,
    attached you will find the screenshot of RAW Tab of the http request ->Response.

    Regards

    Peter
  • RJanecek's avatar
    RJanecek
    Regular Contributor
    hm you can try this as script assertation:

    rawResponse = new String(messageExchange.getRawResponseData())
    rawResponse.contains("<?xml version=\"1.0\" encoding=\"windows-1252\"?>")
  • Christian_Eiche's avatar
    Christian_Eiche
    Occasional Contributor
    Hey,
    thank's that's it.
    Do you have a good hint for groovy scripting documentation?

    Regards

    Peter