将字典作为参数传递给 RobotFramework 测试

编程入门 行业动态 更新时间:2024-10-05 17:26:42
本文介绍了将字典作为参数传递给 RobotFramework 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的机器人测试中有一本字典,我想从调用该测试的程序中填充该字典.我有两个文件:robotstarter.py 和 printdictionary.robot.但是,当我运行脚本时,测试套件中的字典都是空的.我不确定这是 Python 还是 RobotFramework 相关问题.

I have a dictionary in my robot test that I want to be populated from the program that calls the test. I have two files: robotstarter.py and printdictionary.robot. However when I run the script the dictionary inside the test suite are all empty. I'm not sure whether this is a python or RobotFramework related issue.

robotstarter.py

import robot test_dict = {'dict.a': '2', 'dict.b': '2', 'dict.c': '2', 'dict.d': '2', 'dict.e': '2', 'dict.f': '2'} print(test_dict) robot.run("printdictionary.robot", variable=test_dict)

printdictionary.robot

*** Variables *** &{dict} a=${1} b=${1} c=${1} d=${1} e=${1} f=${1} *** Test Cases *** Test print the identity stuff Log To Console \nDictionary: Log To Console ${dict.a} Log To Console ${dict.b} Log To Console ${dict.c} Log To Console ${dict.d} Log To Console ${dict.e} Log To Console ${dict.f}

推荐答案

它的工作原理是用一个数组替换 robotsstarter.py 中的字典.

It works by replacing the dictionary in robotstarter.py with an array.

test_dict = {'dict.a': '2', 'dict.b': '2', 'dict.c': '2', 'dict.d': '2', 'dict.e': '2', 'dict.f': '2'}

变成:

test_dict = {'dict.a:2', 'dict.b:2', 'dict.c:2', 'dict.d:2', 'dict.e:2', 'dict.f:2'}

更多推荐

将字典作为参数传递给 RobotFramework 测试

本文发布于:2023-11-23 21:59:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622964.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字典   参数   测试   RobotFramework

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!