Forum Discussion

rcool123's avatar
13 years ago

Adding xml element to test request using groovy

I am trying to add an element <ns15:containerStatusIdentifier xsi:nil="true"/> dynamically to ns4:statusHistories[1] in the below request before submitting .Can somebody please give me some pointers on how to add this element through groovy ?



<con:updateShoppingCartRequest>
<!--1 or more repetitions:-->
<RequestList>
<con:ShoppingCart xsi:type="con1:ShoppingCart" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<con1:ShoppingCartIdentifier>88910</con1:ShoppingCartIdentifier>
<con1:recordVersionNumber>0</con1:recordVersionNumber>
<ns4:statusHistories>
<ns15:ShoppingCarttatusIdentifier>88911</ns15:ShoppingCarttatusIdentifier>
<ns15:ShoppingCartIdentifier>88910</ns15:ShoppingCartIdentifier>
<ns15:statusTypeCode>SHOPPINGCART</ns15:statusTypeCode>
<ns15:statusCode>CLEARED</ns15:statusCode>
<ns15:currentIndicator>true</ns15:currentIndicator>
</ns4:statusHistories>
<ns4:statusHistories>
<ns15:recordVersionNumber>0</ns15:recordVersionNumber>
<ns15:ShoppingCartIdentifier>88910</ns15:ShoppingCartIdentifier>
<ns15:statusTypeCode>SHOPPINGCART</ns15:statusTypeCode>
<ns15:statusCode>SETUP</ns15:statusCode>
</ns4:statusHistories></con:ShoppingCart>
</RequestList>
</con:updateShoppingCartRequest>
  • MartinS's avatar
    MartinS
    Occasional Contributor
    Hello.

    Make a property in your project (tab overview).

    Like this:
    name: xmlTag
    value: <ns15:containerStatusIdentifier xsi:nil="true"/>

    then place in your test request:
    ${#Project#xmlTag}

    I think this is the easiest way to do it without using groovy.


    Regards,
    MartinS