Forum Discussion
- deepesh_jainFrequent ContributorHello Pallavi,
If the test suites are in the same project and you can use it like below. Remember this code will have to be written in a Groovy script from Test_Suite_2 to access Test_Suite_1:def project = testRunner.testCase.testSuite.project ;
def tcase = project.testSuites["Test_Suite_1"].testCases["Test_Case_A"] ;
def tstep = tcase.getTestStepByName("Test_Step_X");
def response_test_suite_1 = tstep.getProperty("response");
// You can also access individual nodes now from the response you imported like below:
def gutils = new com.eviware.soapui.support.GroovyUtils( context );
def holder = gutils.getXmlHolder("$response_test_suite_1");
def a = holder.getNodeValue("your_xml_xpath_here");
Regards,
Deepesh Jain - PallavibhaskarOccasional ContributorHi Deepesh,
Thank you very much for the quick response, I tried the following, with the help of your code.
----------------------------------------------------------------------------------------------------------------------------
def utils = new com.eviware.soapui.support.GroovyUtils( context );
def project = testRunner.testCase.testSuite.project ;
def tcase = project.testSuites["recordedViewingsReports"].testCases["singleRecordedViewingForIntegratedChannel"] ;
def tstep = tcase.getTestStepByName("assert-getDeliveredViewingReports");
def response_holder = tstep.getProperty("response");
def holder = utils.getXmlHolder("$response_holder");
----------------------------------------------------------------------------------------------------------------------------
The groovy script failed at the last step "def holder = utils.getXmlHolder("$response_holder");" , it returned me a java null pointer exception.
Please find the error logs below:
----------------------------------------------------------------------------------------------------------------------------
Fri Nov 04 14:34:06 GMT 2011:ERROR:java.lang.NullPointerException
java.lang.NullPointerException
at com.eviware.soapui.support.XmlHolder.<init>(XmlHolder.java:52)
at com.eviware.soapui.support.GroovyUtils.getXmlHolder(GroovyUtils.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at Script11.run(Script11.groovy:11)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:96)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148)
at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:274)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680) - deepesh_jainFrequent ContributorHello Pallavi,
My mistake. The line:
def response_holder = tstep.getProperty("response");
returns the property response but not the value of the "response". Update the above line to below:
def response_holder = tstep.getPropertyValue("response");
and it should work.
Let me know if this works.
Regards,
Deepesh Jain - PallavibhaskarOccasional ContributorHello Deepesh,
Thank you very much! It did work - deepesh_jainFrequent ContributorCool.