Forum Discussion

yognsal's avatar
yognsal
Occasional Contributor
7 years ago
Solved

How i can save only limited (say first 100 lines) SOAP UI response in excel sheet using groovy scrip

I want to save only first 100 lines from response which is in JSON format.

 

Because when my response is too big then excel can not hold the entire response in one cell.

so it gets crashed, and i am not able to save a single response in excel.

 

I am using SOAP UI free version. so need groovy script to limit the response, so that excel didnt get crashed.

12 Replies

  • JHunt's avatar
    JHunt
    Community Hero

    The script I gave you updates all Test Cases in the same Test Suite (as the script).

     

    You can go one step further out if you want to update all Test Cases in all Test Suites in the current Project:

     

    testRunner.testCase.project.testSuites.each { testSuite ->
     testSuite.value.testCases.each { testCase -> 
      testCase.value.testSteps.each { 
       def testStep = it.value
       if (testStep instanceof com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep) { 
        testStep.testRequest.setDiscardResponse(true)
       }
      }
     }
    }

     

    • yognsal's avatar
      yognsal
      Occasional Contributor

      Thanks,

       

      Whenever i ran the entire suite after running sometime, it gets freez in between and i cant even able to stop it. I need to close it from task manager. Due to this i am loosing my all the responses which were ran successfully. :( 

      and i need to run 2 3 test cases simultaneously, but it is time consuming. 

      Is there any solution for this, whr i can run it once and dont need to keep an eye on it.

       

      Do you have any idea how i can at least minimize this issue if do not any any other option?

  • JHunt's avatar
    JHunt
    Community Hero

    Make a new test case with this Groovy script and run it to update each RestTestRequestStep in the TestSuite.

     

     

    testRunner.testCase.testSuite.testCases.each { testCase -> 
    	testCase.value.testSteps.each { 
    		def testStep = it.value
    		if (testStep instanceof com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep RestTestRequestStep) { 
    			testStep.testRequest.setDiscardResponse(true)
    		}
    	}
    }

     

    • yognsal's avatar
      yognsal
      Occasional Contributor

      Hi I tried above code but getting below error in if statement -

      if (testStep instanceof com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep RestTestRequestStep) { 

       

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script5.groovy: 52: expecting ')', found 'RestTestRequestStep' @ line 52, column 86. teststeps.RestTestRequestStep RestTestRe ^ org.codehaus.groovy.syntax.SyntaxException: expecting ')', found 'RestTestRequestStep' @ line 52, column 86. at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:143)

       

      FYI..  Mine is not wsdl it's REST request. Can you please help ..

  • JHunt's avatar
    JHunt
    Community Hero

    Sorry, it's just a typo. I had the same thing twice.

     

    testRunner.testCase.testSuite.testCases.each { testCase -> 
    	testCase.value.testSteps.each { 
    		def testStep = it.value
    		if (testStep instanceof com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep) { 
    			testStep.testRequest.setDiscardResponse(true)
    		}
    	}
    }

     Yes, this is for REST request test steps.

    • yognsal's avatar
      yognsal
      Occasional Contributor

      Hi ,

       

      Thanks for the quick reply, but it is not working still.

      Please find the attached image for the structure i have. 

      Can you please see and let me know whr i am missing. I have put the above code in the set up script. and i have two test suits and in test site multiple test cases.

       

      I also tried creating a test case and in that created a groovy script with above code. but when ran it SOAPUI got hanged.

  • JHunt's avatar
    JHunt
    Community Hero

    Is this question related to the previous question? (you are running my script and your SoapUI is crashing?)

     

    Or are you asking a new question about why your Test Suite sometimes crashes? (make a new thread?)

    • yognsal's avatar
      yognsal
      Occasional Contributor

      The script is working fine. But sometime SOAPUI crashes. this is regarding that.