Monday, May 20, 2013

SOAP UI : Adding XPath Assertion to all test steps(same request) in project.

Adding XPath Assertion to all test steps(same request) in project.

TSName = "TestSuiteName"
StepName = "TestStepName"
project.getTestSuiteList().each
{
    if(it.name == TSName)
    {
        TS = it.name
          it.getTestCaseList().each
          {
            TC =it.name
            def asserting = project.getTestSuiteByName(TS).getTestCaseByName(TC).getTestStepByName(StepName).getAssertionByName("XPath Match")
            if (asserting instanceof com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.XPathContainsAssertion)
            {
                project.getTestSuiteByName(TS).getTestCaseByName(TC)getTestStepByName(StepName).removeAssertion(asserting)
            }
                def assertion = project.getTestSuiteByName(TS).getTestCaseByName(TC)getTestStepByName(StepName).addAssertion("XPath Match")
                if(StepName == "TestStepName")
            {
                assertion.path = "declare namespace ns1='http://www.xyz.com/';\n//ns1:StepResponse[1]/ns1:status[1]/ns1:value[1]"
                assertion.expectedContent = "success"
            }
            else
            {
                assertion.path = "declare namespace ns1='http://www.xyz.com/';\n//ns1:StepRequestResponse[1]/ns1:status[1]/ns1:value[1]""
                assertion.expectedContent = "200"
            }
          }
    }
}

No comments:

Post a Comment