Adding XPath Assertion to soap request test steps from Project level(Copy below script in load script of project)
def asserting = project.getTestSuiteByName("StockQuoteService").getTestCaseByName("GetStockQuote").getTestStepByName("GetStockQuote").getAssertionByName("XPath Match")
if (asserting instanceof com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.XPathContainsAssertion)
{
project.getTestSuiteByName("StockQuoteService").getTestCaseByName("GetStockQuote")getTestStepByName("GetStockQuote").removeAssertion(asserting)
}
def assertion = project.getTestSuiteByName("StockQuoteService").getTestCaseByName("GetStockQuote")getTestStepByName("GetStockQuote").addAssertion("XPath Match")
assertion.path = "declare namespace ns1='http://www.restfulwebservices.net/ServiceContracts/2008/01';declare namespace a='http://www.restfulwebservices.net/DataContracts/2008/01';\n //ns1:GetStockQuoteResponse[1]/ns1:GetStockQuoteResult[1]/a:Symbol[1]"
assertion.expectedContent = "CTSH"
if (asserting instanceof com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.XPathContainsAssertion)
{
project.getTestSuiteByName("StockQuoteService").getTestCaseByName("GetStockQuote")getTestStepByName("GetStockQuote").removeAssertion(asserting)
}
def assertion = project.getTestSuiteByName("StockQuoteService").getTestCaseByName("GetStockQuote")getTestStepByName("GetStockQuote").addAssertion("XPath Match")
assertion.path = "declare namespace ns1='http://www.restfulwebservices.net/ServiceContracts/2008/01';declare namespace a='http://www.restfulwebservices.net/DataContracts/2008/01';\n //ns1:GetStockQuoteResponse[1]/ns1:GetStockQuoteResult[1]/a:Symbol[1]"
assertion.expectedContent = "CTSH"
Adding XPath Assertion to soap request test steps from Test Suite level(Copy below script in setup script of test suite)
def asserting = testSuite.getTestCaseByName("GetStockQuote").getTestStepByName("GetStockQuote").getAssertionByName("XPath Match")
if (asserting instanceof com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.XPathContainsAssertion)
{
testSuite.getTestCaseByName("GetStockQuote")getTestStepByName("GetStockQuote").removeAssertion(asserting)
}
def assertion = testSuite.getTestCaseByName("GetStockQuote")getTestStepByName("GetStockQuote").addAssertion("XPath Match")
assertion.path = "declare namespace ns1='http://www.restfulwebservices.net/ServiceContracts/2008/01';declare namespace a='http://www.restfulwebservices.net/DataContracts/2008/01';\n //ns1:GetStockQuoteResponse[1]/ns1:GetStockQuoteResult[1]/a:Symbol[1]"
assertion.expectedContent = "CTSH"
if (asserting instanceof com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.XPathContainsAssertion)
{
testSuite.getTestCaseByName("GetStockQuote")getTestStepByName("GetStockQuote").removeAssertion(asserting)
}
def assertion = testSuite.getTestCaseByName("GetStockQuote")getTestStepByName("GetStockQuote").addAssertion("XPath Match")
assertion.path = "declare namespace ns1='http://www.restfulwebservices.net/ServiceContracts/2008/01';declare namespace a='http://www.restfulwebservices.net/DataContracts/2008/01';\n //ns1:GetStockQuoteResponse[1]/ns1:GetStockQuoteResult[1]/a:Symbol[1]"
assertion.expectedContent = "CTSH"
Adding XPath Assertion to soap request test steps from Test Case level(Copy below script in setup script of test case)
def asserting = testCase.getTestStepByName("GetStockQuote").getAssertionByName("XPath Match")
if (asserting instanceof com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.XPathContainsAssertion)
{
testCase.getTestStepByName("GetStockQuote").removeAssertion(asserting)
}
def assertion = testCase.getTestStepByName("GetStockQuote").addAssertion("XPath Match")
assertion.path = "declare namespace ns1='http://www.restfulwebservices.net/ServiceContracts/2008/01';declare namespace a='http://www.restfulwebservices.net/DataContracts/2008/01';\n //ns1:GetStockQuoteResponse[1]/ns1:GetStockQuoteResult[1]/a:Symbol[1]"
assertion.expectedContent = "CTSH"
if (asserting instanceof com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.XPathContainsAssertion)
{
testCase.getTestStepByName("GetStockQuote").removeAssertion(asserting)
}
def assertion = testCase.getTestStepByName("GetStockQuote").addAssertion("XPath Match")
assertion.path = "declare namespace ns1='http://www.restfulwebservices.net/ServiceContracts/2008/01';declare namespace a='http://www.restfulwebservices.net/DataContracts/2008/01';\n //ns1:GetStockQuoteResponse[1]/ns1:GetStockQuoteResult[1]/a:Symbol[1]"
assertion.expectedContent = "CTSH"
Adding XPath Assertion to soap request test steps using groovy step/script(Copy below script in groovy script test step)
def testst = testRunner.testCase.getTestStepByName("GetStockQuote")
def asserting = testst.getAssertionByName("XPath Match")
if (asserting instanceof com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.XPathContainsAssertion)
{
testst.removeAssertion(asserting)
}
def assertion = testst.addAssertion("XPath Match")
assertion.path = "declare namespace ns1='http://www.restfulwebservices.net/ServiceContracts/2008/01';declare namespace a='http://www.restfulwebservices.net/DataContracts/2008/01';\n //ns1:GetStockQuoteResponse[1]/ns1:GetStockQuoteResult[1]/a:Symbol[1]"
assertion.expectedContent = "CTSH"
def asserting = testst.getAssertionByName("XPath Match")
if (asserting instanceof com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.XPathContainsAssertion)
{
testst.removeAssertion(asserting)
}
def assertion = testst.addAssertion("XPath Match")
assertion.path = "declare namespace ns1='http://www.restfulwebservices.net/ServiceContracts/2008/01';declare namespace a='http://www.restfulwebservices.net/DataContracts/2008/01';\n //ns1:GetStockQuoteResponse[1]/ns1:GetStockQuoteResult[1]/a:Symbol[1]"
assertion.expectedContent = "CTSH"
No comments:
Post a Comment