有人可以帮助我使用脚本来使用groovy脚本从soap UI中的测试用例中捕获脚本日志。
答案 0 :(得分:0)
从这里采取:https://community.smartbear.com/t5/SoapUI-NG/Export-http-log-to-a-file-with-groovy-script/td-p/198
快速注意,脚本日志仅记录log.info日志。此外,日志仅在运行整个测试用例时放入脚本日志中,而不是在手动运行groovy脚本时放入。
def logArea = com.eviware.soapui.SoapUI.logMonitor
if( logArea != null )
{
def ix = logArea.indexOfTab( "Script log" );
if( ix >= 0 )
{
def logPanel = logArea.getComponentAt( ix )
def model = logPanel.logList.model
if( model.size > 0 )
{
def out = new java.io.PrintWriter( "C:/pathtofile/myfile.log" )
for( c in 0..(model.size-1) )
out.println( model.getElementAt( c ))
out.close()
}
}
}
答案 1 :(得分:0)
@canpan以下代码对我有用,感谢您的继续帮助
def logArea = com.eviware.soapui.SoapUI.logMonitor.getLogArea("script log")
def LogFile = new File ("I:/SOAP UI/AutomationFramework/script.txt")
LogFile.write("Generating Script Logs...\r\n")
if (logArea != null)
{
def model = logArea.model
if (model.size > 0)
{
for (c in 0..(model.size-1))
{
LogFile.append(model.getElementAt(c).toString() + "\r\n")
}
}
}