作者raindeer896 (水豚)
看板Python
标题[问题] Robot framework 错误讯息寻问
时间Fri May 12 23:22:12 2023
你好, 我最近在使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://webptt.com/cn.aspx?n=bbs/Python/M.1683904934.A.4AC.html
1F:→ lycantrope: 改int,string就不能当indice05/13 08:39
※ 编辑: raindeer896 (123.110.222.52 台湾), 05/13/2023 09:57:47
2F:→ lycantrope: 你可以把"3000000" 改成 ${3000000}05/13 12:09
※ 编辑: raindeer896 (42.73.97.72 台湾), 05/14/2023 14:50:16
3F:→ raindeer896: 感谢回覆 05/14 14:50