0
votes

I am getting below exception while trying to execute below code:

missing property exception

Code in groovy script for adding xpath assertion into a test case.

Is there any possible solution to solve the error please?

It has test suite name as "ManagePostpayInsurance_1_0" and test step name as "getInsuranceDetails_1_FTC_005".

log.info("Testing Start")
TSName = "ManagePostpayInsurance_1_0"
StepName = "getInsuranceDetails_1_FTC_005"
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")
            assertion.path = "declare namespace cor='http://soa.o2.co.uk/coredata_1';\ndeclare namespace man='http://soa.o2.co.uk/managepostpayinsurancedata_1';\ndeclare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';\n"
            assertion.expectedContent = "200"   
        }
    }

}
log.info("Testing Stop")

Thanks in advance

This is the error log which I am able to see:

Fri Nov 24 10:16:40 IST 2017:ERROR:groovy.lang.MissingPropertyException: No such property: project for class: Script13 groovy.lang.MissingPropertyException: No such property: project for class: Script13 at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50) at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231) at Script13.run(Script13.groovy:7) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:90) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141) at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:250) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

2
Please show full stacktrace of the error. - Rao
Thank you @Rao for looking into it... I am not able to trace where the error exactly is as i cannot debug it step by step...This is the error which i have encountered: "groovy.lang.MissingPropertyException: No such property: project for class: Script 11 error at line 7", Thanks - Sambid Rijal
In the bottom, you can see error log. Clear it by right click and reproduce the issue, capture the log and edit the question and paste the log - Rao
Above mentioned is the error log @Rao , Thanks - Sambid Rijal
Sambid, please check the solution to see if that helps. If that resolves mentioned error it is appreciated if you mark it answered - Rao

2 Answers

1
votes

You can resolve below error

groovy.lang.MissingPropertyException: No such property: project for class: Script13

by adding below statement at the top of your script

def project = context.testCase.testSuite.project
0
votes

You are missing a . dot at getTestCaseByName(TC)getTestStepByName(StepName).