我在尝试执行以下代码时遇到异常:
缺少属性异常
用于将xpath断言添加到测试用例中的groovy脚本中的代码。
有没有可能解决错误的解决方案?
它的测试套件名称为“ManagePostpayInsurance_1_0”,测试步骤名称为“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")
提前致谢
这是我能看到的错误日志:
Fri Nov 24 10:16:40 IST 2017:ERROR:groovy.lang.MissingPropertyException:没有这样的属性:类的项目:Script13 groovy.lang.MissingPropertyException:没有这样的属性:class for class:Script13 在org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50) 在org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49) 在org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231) 在Script13.run(Script13.groovy:7) 在com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:90) 在com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141) 在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) 在java.lang.Thread.run(未知来源)
答案 0 :(得分:1)
您可以解决以下错误
groovy.lang.MissingPropertyException:没有这样的属性:类的项目:Script13
在脚本的顶部添加以下语句
def project = context.testCase.testSuite.project
答案 1 :(得分:0)
您在Id
错过.
点。