差異處
這裏顯示兩個版本的差異處。
rf:rf:upgrade:3.0to3.1.2 [2019/12/01 00:01] tony [Error in file './testdata/data.txt': Unrecognized table header ..] |
rf:rf:upgrade:3.0to3.1.2 [2023/06/25 09:48] |
||
---|---|---|---|
行 1: | 行 1: | ||
- | {{tag>RobotFramework}} | ||
- | ====== 升級RobotFramework從3.0到3.1.2 ====== | ||
- | ===== Square brackets after variable like ${var}[xxx] is considered item access ===== | ||
- | 升級後的錯誤訊息會類似這樣: | ||
- | <code bash> | ||
- | Variable '${phymemory_tabletr_xpath_prefix}' is string, not list or dictionary, and thus accessing item '2' from it is not possible. | ||
- | </code> | ||
- | 原本的語法如下: | ||
- | <code bash> | ||
- | ${phymemory_tabletr_xpath_prefix} | Set Variable | //table[@class='deviceTable']/tbody/tr | ||
- | ${speed_or_size_locator} | Set Variable | ${phymemory_tabletr_xpath_prefix}[2]/th[8] | ||
- | </code> | ||
- | Robot的[[https://github.com/robotframework/robotframework/issues/3004|issue]]有人和我遇到一樣問題,作者提供在index之前加入反斜線的改法: | ||
- | <code bash> | ||
- | ${phymemory_tabletr_xpath_prefix}[2]/th[8] | ||
- | 改為 | ||
- | ${phymemory_tabletr_xpath_prefix}\[2]/th[8] | ||
- | </code> | ||
- | 應該是3.1版本的內容: [[https://github.com/robotframework/robotframework/blob/master/doc/releasenotes/rf-3.1b1.rst#other-issues-possibly-causing-backwards-incompatibility-problems|link]]。 | ||
- | ===== Escaping empty cells with '\' before line continuation marker '...' is deprecated. Remove escaping before Robot Framework 3.2. ===== | ||
- | 目前作者認為'...'是奇怪的語法,打算在3.2中廢掉它,可以參考[[https://github.com/robotframework/robotframework/issues/3148|issue 3148]];而我們最常會遇到的地方是在:For中較長的內容會透過反斜線加'...'去銜接。\\ | ||
- | \\ | ||
- | 另外在3.3要廢掉:FOR語法,改用FOR+END去替代它,可以參考[[https://github.com/robotframework/robotframework/issues/3078|issue 3078。\\ | ||
- | \\ | ||
- | 在FOR LOOP中,這個問題的解法就是使用FOR+END去取代原本的寫法;但不幸地,我目前用1.7.3的RIDE,會幫我把FOR變回:FOR。\\ | ||
- | \\ | ||
- | 因此我決定,等之後再來研究這個問題。 | ||
- | ===== Error in file './testdata/data.txt': Unrecognized table header .. ===== | ||
- | 升級後,Log產生海量的Error且使用新版RIDE也會出現大量的類似錯誤,雖然並不會造成測試不會動,但非常礙眼。這個問題是由於新版的RF在你沒有明確指定測試檔案時,它會去掃工作目錄下所有的txt檔案。針對這個問題,我使用過兩個做法: | ||
- | - 指定測試檔案: 我嘗試過使用simple pattern的方式,如[0-9][0-9]_*.txt;但產生報表時,Test Suite名稱會是由所有檔案名稱串起來的,根本難以閱讀。 | ||
- | - 把副檔名從txt改為robot: 這做法可以根治這問題,但比較麻煩。 | ||
- | 我提供第二種做法細節給大家參考。之所以麻煩,是由於原本使用txt的方式,代表Resource參考方式也是;這意味著除了要修改檔案名稱外,還要修改測試內容。因此,可以參考以下步驟去解決這問題: | ||
- | - 寫一隻程式,列出放測試案例目錄下所有的txt檔案路徑,並寫到檔案中。 | ||
- | - Review這隻檔案,排除不需要轉換的項目。 | ||
- | - 寫一隻程式,讀取各路徑的檔案內容;以行為處理單位,將Resource開頭的行中,.txt結尾字串取代為.robot。 | ||
- | - 寫一隻程式,將各路徑的檔案rename,將附檔名從.txt改為.robot。 | ||
- | - 最後就是在你的robot執行命令加上--extension robot,問題解決。 | ||