Python Robot框架预期错误失败:索引器错误:列表索引超出范围
我有一个机器人框架的问题 目前我做阴性测试。我有一个JSON响应,长度为数组Python Robot框架预期错误失败:索引器错误:列表索引超出范围,python,python-2.7,automation,automated-tests,robotframework,Python,Python 2.7,Automation,Automated Tests,Robotframework,我有一个机器人框架的问题 目前我做阴性测试。我有一个JSON响应,长度为数组5data(从0开始计数)。我想检查6th是否存在。如果6th数据不存在,则测试通过 这是我的密码: ${msg} Run Keyword And Expect Error Resolving variable '${json_response['data'][5]}' failed: IndexError: list index out of range * Log To Console
5
data(从0开始计数)。我想检查6
th是否存在。如果6
th数据不存在,则测试通过
这是我的密码:
${msg} Run Keyword And Expect Error Resolving variable '${json_response['data'][5]}' failed: IndexError: list index out of range * Log To Console ${json_response['data'][5]}
Should Contain ${msg} failed: IndexError: list index out of range
代码给出了失败的结果
如何解决此问题?更好的方法是验证列表长度是否为预期长度:
${json_length} Get Length ${json_response['data']}
Should Be Equal As Integers ${json_length} 6
请提供变量值的示例,以及
登录控制台调用的实际结果。