Forum Discussion

naveen8944's avatar
naveen8944
Contributor
9 years ago

Need help in creating dynamic assertion

HI All

 

I'm in the process of creating dynamic assertions using groovy in SoapUI(Not PRO). I 'm able to add the assertion using the following successfully

 

 

def teststep = testRunner.testCase.getTestStepByName("TestStep_Name");
teststep.addAssertion("XPath Match")

 

 

Can anyone please help how I can add the XPath Expression and Expected Result  for the above step

 

  • Found the solution after going through the API

     

    def teststep = testRunner.testCase.getTestStepByName("TestStep_Name");

    def xpathassertion = teststep.addAssertion("XPath Match")  // Adds the assertion
    xpathassertion.name = "xpath assertion"    // This is name of the assertion 
    xpathassertion.setPath("path") // This is the Xpath Expression
    xpathassertion.setExpectedContent("expected value") // As the title says..expected value

     

    Happy Coding !!

  • Found the solution after going through the API

     

    def teststep = testRunner.testCase.getTestStepByName("TestStep_Name");

    def xpathassertion = teststep.addAssertion("XPath Match")  // Adds the assertion
    xpathassertion.name = "xpath assertion"    // This is name of the assertion 
    xpathassertion.setPath("path") // This is the Xpath Expression
    xpathassertion.setExpectedContent("expected value") // As the title says..expected value

     

    Happy Coding !!