差異處

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

連向這個比對檢視

Both sides previous revision 前次修改
下次修改
前次修改
rf:rf:unnecessarylog [2015/11/07 18:29]
tony [How to?]
rf:rf:unnecessarylog [2023/06/25 09:48] (目前版本)
行 1: 行 1:
 {{tag>​RobotFramework}} {{tag>​RobotFramework}}
 ====== 處理不必要的Log ====== ====== 處理不必要的Log ======
-===== Problem ​===== +===== Introduction ​===== 
-RobotFramework ​SeleniumLibrary某些Keyword,有提供loglevel的參數;在發生錯誤時,會將所有的網頁內容抓下來。當你有做retry時,或沒有做retry,這log的量都非常可觀,甚至可能讓你out of memory。然而,並非每個開發人員都會注意到這點。目前提供手動偵測方式,找尋與修改,並分享我使用的方法。(也許以後可以自動化)\\ +SeleniumLibrary某些Keyword,有提供loglevel的參數;在發生錯誤時,會將所有的網頁內容抓下來。當你有做retry時,或沒有做retry,這log的量都非常可觀,甚至可能讓你out of memory。然而,並非每個開發人員都會注意到這點。因此希望能透過工具或程式化的偵測方式,出這些問題並修改。\\
-另外可以參考[[http://​robotframework-seleniumlibrary.googlecode.com/​hg/​doc/​SeleniumLibrary.html?​r=2.9.1|官方文件]],在你測試中有用到包含loglevel=INFO的那些keywords。\\+
 \\ \\
-註: 還無法完全涵蓋所有情形。 +處理文字檔的方式比較簡單,但不幸地,我們使用html的原始檔,也造成判別上比較困難些。慶幸的是,Robot在html的格式上,有固定規則:​ 一個tr包含5個td,而主要內容由第二個td開始。因此,我們只要針對要處理的keyword,分別在其它四個位置所造成影響,做整理與探討。\\
-===== How to? ===== +
-也許處理文字檔的方式比較簡單,但不幸地,我們使用html的原始檔,也造成判別上比較困難些。慶幸的是,Robot在html的格式上,有固定規則:​ 一個tr包含5個td,而主要內容由第二個td開始。因此,我們只要針對要處理的keyword,分別在其它四個位置所造成影響,做整理與探討。我針對參數數量做分類:​ +
-==== Page Should Contain | Page Should Not Contain ==== +
-目前我透過Eclipse搜尋有問題的keyword並調整。以下圖為例,包含六個不必要的log,\\ +
-{{:​rf:​rf:​rf_ignore_log_psc_robot.png?​600|}}\\+
 \\ \\
-在Eclipse Search使用regular expression,\\+目前我所使用的偵測方式是Eclipse的File Search with Regular Expression :\\
 {{:​rf:​rf:​rf_ignore_log_psc_eclipse.png?​600|}}\\ {{:​rf:​rf:​rf_ignore_log_psc_eclipse.png?​600|}}\\
 \\ \\
-們要處理這幾種種情況,先成兩大類: 有内縮(For)與無內縮; +===== Category ===== 
-<code bash> +以下是針對參數數量所做的分類: ​ 
-# 在 Page Should ​(Not )?Contain | ${some_words}後有一個空格,html為<​td></​td>:​ +(可以參考[[http://​robotframework-seleniumlibrary.googlecode.com/​hg/​doc/​SeleniumLibrary.html?​r=2.9.1|官方文件]],確認你的測試中所用的keywords,哪些有支援loglevel的參數
-<td>Page Should Contain</​td>​\s<​td>​.*</​td>​\s<​td></​td>​+  * [[rf:​rf:​unnecessarylog:​psc|Page Should Contain | Page Should ​Not Contain]] 
 +  ​[[rf:​rf:​unnecessarylog:​psce|Page Should Contain Element | Page Should Not Contain Element]] @TODO@
  
-# Page Should (Not )?Contain | ${some_words}後沒有空格,html為</​tr>​;但若有設定NONE且那行較長的情況下,NONE在html中會被存到下個<​tr>​中:​ 
-<​td>​Page Should Contain</​td>​\s<​td>​.*</​td>​\s</​tr>​(?​!\s<​tr>​\s<​td class="​name"></​td>​\s<​td>​...</​td>​\s<​td>​NONE</​td>​)$ 
- 
-# 總和兩者:​ 
-<​td>​Page Should (Not )?​Contain</​td>​\s<​td>​.*</​td>​\s(<​td></​td>​|</​tr>​(?​!\s<​tr>​\s<​td class="​name"></​td>​\s<​td>​...</​td>​\s<​td>​NONE</​td>​)$) 
-</​code>​ 
-依照html修改方法,分成三類:​ (1) 在已有的<​td>​ - loglevel欄位填入NONE;(2) 在內縮區塊,必須額外插入<​tr>​;(3) 在無內縮區塊,必須額外插入<​tr>:​\\ 
-直接修改網頁的方式,第一種情況只要直接加上NONE即可:​ 
-<code html> 
-<!-- 修改前 --> 
-<tr> 
-<td class="​name"></​td>​ 
-<​td>​Page Should Contain</​td>​ 
-<​td>​Computer Summary</​td>​ 
-<​td></​td>​ 
-<​td></​td>​ 
-</tr> 
-<!-- 修改後 --> 
-<tr> 
-<td class="​name"></​td>​ 
-<​td>​Page Should Contain</​td>​ 
-<​td>​Computer Summary</​td>​ 
-<​td>​NONE</​td>​ 
-<​td></​td>​ 
-</tr> 
-</​code>​ 
-第二種情況必須視第一個區塊<​td>​數量,去加入新的<​tr>​與對應的<​td>:​ 
-<code html> 
-<!-- 修改前 --> 
-<tr> 
-<td class="​name"></​td>​ 
-<​td>​Run Keyword If</​td>​ 
-<​td>​${col_count} == 0</​td>​ 
-<​td>​Page Should Contain</​td>​ 
-<​td>​Not Available</​td>​ 
-</tr> 
-<!-- 插入下方區塊 --> 
-<tr> 
-<td class="​name"></​td>​ 
-<​td>​...</​td>​ 
-<​td>​NONE</​td>​ 
-<​td></​td>​ 
-<​td></​td>​ 
-</tr> 
-</​code>​ 
-==== Page Should Contain Element | Page Should Not Contain Element ==== 
-與Page Should Contain比較起來,在於Keyword多一個參數。因此要做小小的調整:​ 
-<code bash> 
-<​td>​Page Should (Not )?Contain Element</​td>​\s<​td>​.*</​td>​\s(<​td></​td>​|</​tr>​(?​!\s<​tr>​\s<​td class="​name"></​td>​\s<​td>​...</​td>​\s<​td>​NONE</​td>​)$) 
-</​code>​ 
-直接修改網頁的方式,第一種情況只要直接加上NONE即可:​ 
-<code html> 
-<!-- 修改前 --> 
-<tr> 
-<td class="​name"></​td>​ 
-<​td>​Page Should Contain Element</​td>​ 
-<​td>//​span[text()='​test'​]</​td>​ 
-<​td>​MSG</​td>​ 
-<​td></​td>​ 
-</tr> 
-<!-- 修改後 --> 
-<tr> 
-<td class="​name"></​td>​ 
-<​td>​Page Should Contain Element</​td>​ 
-<​td>//​span[text()='​test'​]</​td>​ 
-<​td>​MSG</​td>​ 
-<​td>​NONE</​td>​ 
-</tr> 
-</​code>​ 
- 
-==== Test ==== 
-<​code>​ 
-|K|I||| 
-|K|I|log|| 
-|AK||K|I|| 
-|AK|K|I|log| 
--> <​td>​Page Should Contain</​td>​\s<​td>​.+</​td>​\s<​td></​td>​ 
- 
-|AK|AK|AK|K| 
-|I|log||| 
--> <​td>​Page Should Contain</​td>​\s</​tr>​\s<​tr>​\s<​td class="​name"></​td>​\s<​td>​...</​td>​\s<​td>​.+</​td>​\s<​td></​td>​ 
--> <​td>​Page Should Contain</​td>​\s</​tr>​\s<​tr>​\s<​td class="​name"></​td>​\s<​td></​td>​\s<​td>​...</​td>​\s<​td>​.+</​td>​\s<​td></​td>​ 
- 
--> <​td>​Page Should Contain</​td>​\s(</​tr>​\s<​tr>​\s<​td class="​name"></​td>​\s(<​td></​td>​\s)?<​td>​...</​td>​\s<​td>​.+</​td>​\s<​td></​td>​|<​td>​.+</​td>​\s<​td></​td>​) 
- 
- 
-|AK|AK|K|I| 
-|log|||| 
--> <​td>​.+</​td>​\s<​td>​.+</​td>​\s<​td>​Page Should Contain</​td>​\s<​td>​.+</​td>​\s</​tr>​(?​!\s<​tr>​\s<​td class="​name"></​td>​\s<​td>​...</​td>​\s<​td>​NONE</​td>​)$ 
- 
- 
-||AK|K|I| 
-||log||| 
--> <​td></​td>​\s<​td>​.+</​td>​\s<​td>​Page Should Contain</​td>​\s<​td>​.+</​td>​\s</​tr>​(?​!\s<​tr>​\s<​td class="​name"></​td>​\s<​td></​td>​\s<​td>​...</​td>​\s<​td>​NONE</​td>​)$ 
- 
-||AK|AK|K| 
-||I|Log|| 
--> <​td></​td>​\s<​td>​.+</​td>​\s<​td>​.+</​td>​\s<​td>​Page Should Contain</​td>​\s</​tr>​\s<​tr>​\s<​td class="​name"></​td>​\s<​td></​td>​\s<​td>​...</​td>​\s<​td>​.+</​td>​\s<​td></​td>​ 
-</​code>​ 
 =====    ===== =====    =====
 ---- ----
 \\ \\
 ~~DISQUS~~ ~~DISQUS~~