Pages - Menu

2019年10月31日 星期四

[Katalon Studio]顯示訊息或文字

前言

一般寫程式在除錯的時候,看執行到哪裡就印個字串出來,
代表執行到這,或是判斷有沒有執行,當然,也可以透過除錯模式去檢查。
但有些問題是當下沒事,過了一陣子後才冒出來,此時要找錯在哪就不好處理了。
將字串印出來有下面幾種方式



正文

1.

System.out.println(msg)

會在主控台看到列印的訊息(Fig.1)


(Fig.1)
2.使用log參數

import com.kms.katalon.core.logging.KeywordLogger
KeywordLogger log = new KeywordLogger()
log.logInfo(today)
log.logPassed(today)
log.logFailed(today)
log.logError(today)
log.logWarning(today)

之後即可在Log Viewer上看到訊息(上面的層級,代表要再哪個層級上看(Fig. 2))

(Fig. 2)
一開始預設是Tree View 需取消才看的到(Fig. 3)

(Fig. 3)
附註:字串的相加方式
System.out.println(  item_no + " Not Found")
String.format(‘abcd %s efg %s hijk’,item_no,item_no)

ref. unable to print message in Log Viewer

沒有留言:

張貼留言