mh350
8 years agoOccasional Contributor
How to dynamically add Script Assertion, when addAssertion returns null
Hi
I am trying to use groovy to add Script Assertion, I've found out in this forum I had to use addAssertion. Problem is that method returns null so I went back to this forum and I found this:
import com.eviware.soapui.config.AssertionEntryConfig
import com.eviware.soapui.impl.wsdl.teststeps.assertions.support.AssertionEntry
import com.eviware.soapui.config.AssertionTestStepConfig
def factoryinstance = AssertionTestStepConfig.Factory.newInstance()
def testStep = context.testCase.testSteps["Assertion TestStep"];
def source = context.testCase.testSteps["Test Request"];
def entry1 = new AssertionEntry(factoryinstance.insertNewEntry(0) , testStep.getTestStep() )
def parent = null
def entry = entry1.buildAssertionEntry("XPath Match", "Xpath", false, testStep, source, "Response",parent)
testStep.addAssertionEntry(entry)
which seems to have worked according to the discussion.
Question is how can I adapt it so it handles Script Assertion instead of Xpath Assertion ?
Best regards!