Forum Discussion
5 Replies
- Hi,
You can add assertions using script and once added you can disable the custom groovy event handler,
RequestFilter.filterRequest is the custom event handler
http://www.soapui.org/Scripting-Propert ... dlers.html
Example for Xpath assertion
def assertion = request.addAssertion("XPath Match")
assertion.path = "declare namespace ns1='http://www.xyz.com/xyz/abc/v1/xyz';\n//ns1:parentnode[1]/ns1:status[1]/ns1:value[1]"
assertion.expectedContent = "true"
Here is more information about Assertion API,
http://www.soapui.org/apidocs/com/eviwa ... mmary.html
http://www.soapui.org/apidocs/com/eviwa ... rtion.html
http://www.soapui.org/apidocs/com/eviwa ... rtion.html
Thanks,
Jeshtha - jsreesoapContributordisable the custom groovy event handler?
I did not create any for assertion. Do I add this script in even handler and dont specify a target?
Thanks for your help - Hi,
I believe what Jeshtha is saying is to add that code to the event handler RequestFilter.filterRequest, and when it is executed the assertion will be created. Then disable the event handler (by clicking the Disable check box) so it will not create the assertion again.
Regards,
Marcus
SmartBear Support - jsreesoapContributorGot it. Thanks Marcus. Since I am new I am not sure what I should provide for the name space, I mean what URL. Could you pls let me know?
I need the check on the header.The header returns 201. I do not see any option in the script to add that.Basically I need a method/script which would check the header in each test case responses for 201
Thanks again for your help - Hi,
We (SmartBear SoapUI Pro Support) do not support custom code solutions, please keep this in mind while posting in the pro forums.
You should be able to use the SubmitListener.afterSubmit event handler with the following code Jestha posted previously and the code I'm adding to it to get the status.
def headers = submit.response.responseHeaders
def status = headers.get("#status#").get(0).split(" ")
def statusValue = status[1]
if (statusValue == 201)
{
def assertion = submit.request.addAssertion("XPath Match")
assertion.path = "declare namespace ns1='http://www.xyz.com/xyz/abc/v1/xyz';\n//ns1:parentnode[1]/ns1:status[1]/ns1:value[1]"
assertion.expectedContent = "true"
}
Regards,
Marcus
SmartBear Support