cancel
Showing results for 
Search instead for 
Did you mean: 

[Resolved] Possible to clear Log Output console using Groovy

SOLVED
Contributor

[Resolved] Possible to clear Log Output console using Groovy

Hi there,

I'm just wondering if I can clear the log output console through a groovy method?

Cheers,
Richard
Member of the SOAPUI Product Advisory Board
1 ACCEPTED SOLUTION

Accepted Solutions
Contributor

Re: Possible to clear Log Output console using Groovy

com.eviware.soapui.SoapUI.logMonitor.getLogArea("Script Log").clear()

 Capital S and Capital L in "Script Log"

then it works fine , thanks

 

11 REPLIES 11

Re: Possible to clear Log Output console using Groovy

Hello,

yes - you can use

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

Regards,
Vladimir
SmartBear Software


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.
Contributor

Re: Possible to clear Log Output console using Groovy

Great - thanks for the response!
Member of the SOAPUI Product Advisory Board
Occasional Contributor

Re: Possible to clear Log Output console using Groovy

Actually it should be:

 

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

 

Note the capital S.

Contributor

Re: Possible to clear Log Output console using Groovy

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()

Community Hero

Re: Possible to clear Log Output console using Groovy

Been looking for this for some time. Awesome! 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Occasional Contributor

Re: Possible to clear Log Output console using Groovy

 

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

Occasional Contributor

Re: [Resolved] Possible to clear Log Output console using Groovy

looks like the "com.eviware.soapui.SoapUI.logMonitor.getLogArea( "Script  log" )" always returns null with ReadyAPI 2.3.0, no matter if executed in groovy teststep script or as Setup Script on testcase or testsuite level

Occasional Contributor

Re: [Resolved] Possible to clear Log Output console using Groovy

though they should not make such changes

 

try with capital L it works

 

i mean change "Scipt log" to "Script Log"

 

com.eviware.soapui.SoapUI.logMonitor.getLogArea("Script Log").clear()

 version changed.jpg

Occasional Contributor

Re: [Resolved] Possible to clear Log Output console using Groovy

yes exactly that's the point: it's case sensitive and the name of the log file area has to be set exactly as it appears on the UI - unfortunately they use different versions all over the place:

SoapUI 5.4.0: "script log"

ReadyAPI 2.2.0: "Script log"

ReadyAPI 2.3.0: "Script Log"

Smiley Frustrated

 

another interesting question regarding this topic is why the statement

"com.eviware.soapui.SoapUI.logMonitor.getLogArea( "..." )"

works if executed manually via UI but fails if executed automatically via maven plugin on the CI:

NullPointerException: Cannot invoke method getLogArea() on null object

another post mentioned the same already guessing that it only works in the environment with a UI present, but I am curious if we really have to live with that or if there's asolution to get this working in maven as well

 

New Here?
Join us and watch the welcome video:
6 / 7 API Testing Mistakes Video
Top Kudoed Authors