差異處

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

連向這個比對檢視

rf:rf:unnecessarylog [2015/11/07 18:05]
tony
rf:rf:unnecessarylog [2023/06/25 09:48]
行 1: 行 1:
-{{tag>​RobotFramework}} 
-====== 處理不必要的Log ====== 
-===== Problem ===== 
-RobotFramework 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。\\ 
-\\ 
-註: 還無法完全涵蓋所有情形。 
-===== How to? ===== 
-也許處理存文字檔的方式比較簡單,但不幸地,我們使用html的原始檔。 
-==== Page Should Contain | Page Should Not Contain ==== 
-目前我透過Eclipse搜尋有問題的keyword並調整。以下圖為例,包含兩個不必要的log,\\ 
-{{:​rf:​rf:​rf_ignore_log_psc_robot.png?​600|}}\\ 
-\\ 
-在Eclipse Search使用regular expression,\\ 
-{{:​rf:​rf:​rf_ignore_log_psc_eclipse.png?​600|}}\\ 
-\\ 
-我們要處理的這兩種情況,包含:​ 
-<code bash> 
-# 在 Page Should (Not )?Contain | ${some_words}後有一個空格,html為<​td></​td>:​ 
-<​td>​Page Should Contain</​td>​\s<​td>​.*</​td>​\s<​td></​td>​ 
  
-# 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>​ 
-直接修改網頁的方式,第一種情況只要直接加上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~~