gpt4 book ai didi

python-3.x - 将字典作为参数传递给 RobotFramework 测试

转载 作者:行者123 更新时间:2023-12-04 13:45:20 29 4
gpt4 key购买 nike

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

Result of running the script

robotsstarter.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}

最佳答案

不支持通过命令行参数变量传递字典。 documentation on command line variables明确指出仅支持标量变量。

... Only scalar variables can be set using this syntax and they can only get string values. ...



如果要传递任何类型的层次结构,则必须通过变量文件传递。这可以是对 YAML 文件的引用,也可以是声明字典的 Python 文件,或返回所需变量的 Python 方法/类。示例可以在 documentation on variable files 中找到.

关于python-3.x - 将字典作为参数传递给 RobotFramework 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49652106/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com