Forum Discussion

gauravkhurana's avatar
gauravkhurana
Occasional Contributor
7 years ago
Solved

How to clear Log Ouput via groovy

I would like to clear the "log Output" before running the test cases.

 

Reason:- I would not like to see the output of the previous run as it creates confusion. 

 

while i have seen in the forum the below command, but it does not work.

 

com.eviware.soapui.SoapUI.logMonitor.getLogArea("script log").clear()

 

It does not clear the previous log output. I have put this as both first and last line of my groovy script but it does not clear the script log window.

  • gauravkhurana's avatar
    gauravkhurana
    7 years ago

    Below code actually clears the "log-output"

     

    Ready aPI 2.1

     

    import com.eviware.soapui.SoapUI

    log.info("test")

    //Writing to the log is executed in the separate thread, so it is need to wait some time to get all notifications.

    sleep(1000)

    def teststep = context.getCurrentStep()

    def tesStepPanel = SoapUI.getDesktop().getDesktopPanel(teststep)

    if(tesStepPanel != null) {

     tesStepPanel.getComponent(2).getComponent(0).getComponent(1).getComponent(2).getComponent(0).clear()

    }

     

    Note that in ReadyAPI 2.2 you will need to use the following script:

    import com.smartbear.ready.core.ApplicationEnvironment

    log.info("test")

    //Writing to the log is executed in the separate thread, so it is need to wait some time to get all notifications.

    sleep(1000)

    def teststep = context.getCurrentStep()

    def tesStepPanel = ApplicationEnvironment.getDesktop().getDesktopPanel(teststep)

    if(tesStepPanel != null) {

    tesStepPanel.getComponent(3).getComponent(0).getComponent(1).getComponent(2).getComponent(0).clear()

    }

     

    Don't forget to kudos/accept this as a solution

6 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    Quoting from this thread:https://community.smartbear.com/t5/SoapUI-Pro/Resolved-Possible-to-clear-Log-Output-console-using-Groovy/m-p/23901/highlight/true#M11375

     

     

    Note that below command only works if you run your tests from " Test case"  or the " Test Steps group" -> just below test case name".
     
    If you try to run below from a stand alone groovy step, this will not clear the log. Be aware! Had us wondering for few days. 
     
    com.eviware.soapui.SoapUI.logMonitor.getLogArea("Script log").clear()

     

    I've never managed to get it to work for me though.

     

    • gauravkhurana's avatar
      gauravkhurana
      Occasional Contributor

      groovyguy wrote:

      Quoting from this thread:https://community.smartbear.com/t5/SoapUI-Pro/Resolved-Possible-to-clear-Log-Output-console-using-Groovy/m-p/23901/highlight/true#M11375

       

       

      Note that below command only works if you run your tests from " Test case"  or the " Test Steps group" -> just below test case name".
       
      If you try to run below from a stand alone groovy step, this will not clear the log. Be aware! Had us wondering for few days. 
       
      com.eviware.soapui.SoapUI.logMonitor.getLogArea("script log").clear()

       

      I've never managed to get it to work for me though.

       


      Hey thanks  a lot msiadak for this information.

       

      Its working the way you told. It only clears the log if we run the groovy script as part of test case execution. Looks like this command is for clearing the "script log" and not for "Log output" 

       

      It clears the "script log" which comes adjacent to "memory log" and not clears the "Log output" when run as a testcase and not as groovy

       

      So the question is still there "How can we clear the "Log Output" "?

       

      • gauravkhurana's avatar
        gauravkhurana
        Occasional Contributor

        Below code actually clears the "log-output"

         

        Ready aPI 2.1

         

        import com.eviware.soapui.SoapUI

        log.info("test")

        //Writing to the log is executed in the separate thread, so it is need to wait some time to get all notifications.

        sleep(1000)

        def teststep = context.getCurrentStep()

        def tesStepPanel = SoapUI.getDesktop().getDesktopPanel(teststep)

        if(tesStepPanel != null) {

         tesStepPanel.getComponent(2).getComponent(0).getComponent(1).getComponent(2).getComponent(0).clear()

        }

         

        Note that in ReadyAPI 2.2 you will need to use the following script:

        import com.smartbear.ready.core.ApplicationEnvironment

        log.info("test")

        //Writing to the log is executed in the separate thread, so it is need to wait some time to get all notifications.

        sleep(1000)

        def teststep = context.getCurrentStep()

        def tesStepPanel = ApplicationEnvironment.getDesktop().getDesktopPanel(teststep)

        if(tesStepPanel != null) {

        tesStepPanel.getComponent(3).getComponent(0).getComponent(1).getComponent(2).getComponent(0).clear()

        }

         

        Don't forget to kudos/accept this as a solution