[問題] Robot framework 錯誤訊息尋問

看板Python作者 (水豚)時間11月前 (2023/05/12 23:22), 11月前編輯推噓0(003)
留言3則, 2人參與, 11月前最新討論串1/1
你好, 我最近在使robot framework做測試, 發生錯誤訊息如下, 想請問如何修正? 我跑了以下command robot robot_test 錯誤訊息: TypeError: string indices must be integers, not 'str' 我的檔案一共有三個 1. robot_test_features.robot https://imgur.com/ 2. robot_test_keywords.robot https://imgur.com/ 3. robot_test_steps.py https://imgur.com/ 4. 測試結果 https://imgur.com/ 我發現我執行 robot robot_test 會出現錯誤, 想問如何修正 以下是我的嘗試 (1) 我一開始以為是我robot_test_steps.py python寫錯 assert _tradingFeeRateDict[0]["twdVolume"] == "3000000" assert 設定錯誤, 但是我把它print 出來又發現是正確 print(_tradingFeeRateDict[0]["twdVolume"]) 結果真的是 "3000000" (2) 後來想說是type 沒對上, 但是又發現都是str print(type(_tradingFeeRateDict[0]["twdVolume"]))結果真的是 #<class 'str'>, yes this is str (3)那不然單跑這之python的unit test 看看 https://imgur.com/D9OEomw
結果還是通過 def 的function 看起來很正常 好吧, 我真的不知道我為什麼跑 robot robot_test 會失敗,想問如何修正 以上問題謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.110.222.52 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1683904934.A.4AC.html

05/13 08:39, 11月前 , 1F
改int,string就不能當indice
05/13 08:39, 1F
※ 編輯: raindeer896 (123.110.222.52 臺灣), 05/13/2023 09:57:47

05/13 12:09, 11月前 , 2F
你可以把"3000000" 改成 ${3000000}
05/13 12:09, 2F
※ 編輯: raindeer896 (42.73.97.72 臺灣), 05/14/2023 14:50:16

05/14 14:50, 11月前 , 3F
感謝回覆
05/14 14:50, 3F
文章代碼(AID): #1aNbccIi (Python)