差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

Both sides previous revision 前次修改
下次修改
前次修改
rf:rf:reducelog [2016/02/26 10:56]
tony [等到網頁不包含XXX]
rf:rf:reducelog [2023/06/25 09:48] (目前版本)
行 1: 行 1:
 ====== 減少產生不必要的Log ====== ====== 減少產生不必要的Log ======
 ===== Introduction ===== ===== Introduction =====
-隨著testcases越來越多,我們這陣子開始有報表無法出現的問題。後來發現是由於output.xml就有46~50MB的大小,在產生報表時會發生out of memory。這大小光要透過編輯器打開就很吃力了後來暫時解決方式是透過commandline自行產生報表:​+隨著testcases越來越多,我們這陣子開始有報表無法出現的問題。後來發現是由於output.xml就有46~50MB的大小,在產生報表時會發生out of memory。這大小光要透過編輯器打開就很吃力了後來暫時解決方式是透過commandline自行產生報表:​
 <code bash> <code bash>
 java -jar robotframework.jar rebot output.xml java -jar robotframework.jar rebot output.xml
行 17: 行 17:
 Wait Until Page Does Not Contain Element | ${locator} | ${timeout} Wait Until Page Does Not Contain Element | ${locator} | ${timeout}
 </​code>​ </​code>​
-可用Keywords:​ Wait Until Page Does Not Contain Element與Wait Until Page Does Not Contain+**可用Keywords:​** **Wait Until Page Does Not Contain Element****Wait Until Page Does Not Contain**
 ==== 等到網頁包含XXX ==== ==== 等到網頁包含XXX ====
 不管在Selenium1還是2,可能都有人會透過以下寫法去做等到網頁包含XXX:​ 不管在Selenium1還是2,可能都有人會透過以下寫法去做等到網頁包含XXX:​
行 27: 行 27:
 Wait Until Page Contains Element | ${locator} | ${timeout} Wait Until Page Contains Element | ${locator} | ${timeout}
 </​code>​ </​code>​
 +**可用Keywords:​** **Wait Until Page Contains Element**與**Wait Until Page Contains**。
 +==== 檔案內容是否包含 ====
 +有時我們會檢查某個檔案內容是否包含特定字串:​
 +<​code>​
 +${content} | Get File | ${file}
 +Should Contain | ${content} | ${expect_str}
 +</​code>​
 +在發生錯誤時,會將整個檔案內容給log下來。如果檔案內容是值得參考的,也許你會直接log下來;但我會將當時的檔案複製一份,再透過log去連結它:​ [[rf:​rf:​reservefile|link]]。如果抓取檔案不是問題,接下來就是減少錯誤發生時所造成的大量log。我透過Grep File,去取代Get File:
 +<​code>​
 +${ret} | Grep File | ${file} | ${expect_str}
 +Should Not Be Empty | ${ret}
 +</​code>​
 +另外一個方式是將,Should Contain的values參數設定為False:​
 +<​code>​
 +${content} | Get File | ${file}
 +Should Contain | ${content} | ${expect_str} | values=False
 +</​code>​
 +不少判斷內容的keyword都支援此參數,缺點是Get File的動作還是會log部分內容。\\
 +**可用Keywords:​** **Grep File**
 +==== 設定Retry/​Wait Keyword的Log Level ====
 +這部分可參考另外一篇:​
 +  * [[rf:​rf:​unnecessaryLog|設定某些Keyword的Log Level]] @TODO@
 +==== Set Log Level ====
 +在某些retry動作內有包含log keyword時,可以在使用前透過Set Log Level為NONE去避免不必要的LOG,然後在teardown在回復成INFO。
 +==== 使用--RemoveKeywords參數 ====
 +以**Wait Until Keyword Succeeds**來說,Robot設計者已考量到大量log產生問題,因此可以在robot參數加入以下參數,去濾掉不必要的報表內容:​
 +<code bash>
 +--RemoveKeywords WUKS
 +</​code>​
 +PS. output.xml中依然會有這些東西,但report.html中是被濾掉的。
 ===== Reference ===== ===== Reference =====
   * [[http://​robotframework.org/​robotframework/​latest/​RobotFrameworkUserGuide.html#​standalone-jar-distribution|RobotFrameworkUserGuide.html#​standalone-jar-distribution]]   * [[http://​robotframework.org/​robotframework/​latest/​RobotFrameworkUserGuide.html#​standalone-jar-distribution|RobotFrameworkUserGuide.html#​standalone-jar-distribution]]
行 32: 行 62:
   * [[http://​robotframework-seleniumlibrary.googlecode.com/​hg/​doc/​SeleniumLibrary.html|SeleniumLibrary]]   * [[http://​robotframework-seleniumlibrary.googlecode.com/​hg/​doc/​SeleniumLibrary.html|SeleniumLibrary]]
   * [[http://​robotframework.org/​robotframework/​latest/​libraries/​BuiltIn.html|Builtin]]   * [[http://​robotframework.org/​robotframework/​latest/​libraries/​BuiltIn.html|Builtin]]
 +  * [[http://​robotframework.org/​robotframework/​latest/​libraries/​OperatingSystem.html|OperatingSystem]]