如何将值从python代码传递给机器人框架的变量 [英] how to pass values from python code to variable of robot framework
问题描述
我是机器人框架的初学者.我想将python文件中的值传递给机器人框架的变量,但仍然无法成功.
I'm beginner in robot framework. I want to pass values from python file to variable of robot framework, but still can't work successfully.
globe.py
是我的 python 文件,它非常简单.
globe.py
is my python file and it's very simple.
a = 'this is testing'
以下是机器人所需的测试用例配置
below is test case configuration as robot required
*** Setting ***
|Variables|globe.py
*** Variables ***
|${myTest}|${a}
但是机器人抛出错误:
文件错误:设置变量 '${myTest}' 失败:未找到变量 '${a}'."
"Error in file: Setting variable '${myTest}' failed: Variable '${a}' not found."
你能就此提出一些建议吗?
could you give some suggestion on that?
推荐答案
在我看来,您的示例确实有效.我使用制表符分隔的方法,但这不应该是原因.
It seems to me that your example does work. I use the tab delimited approach, but that shouldn't be the cause.
*** Setting ***
Variables globe.py
*** Variables ***
${myTest} ${a}
*** Test Cases ***
A Test Case
Log To Console ${myTest}
这导致了 Robot Framework 的响应,这似乎是您正在寻找的内容.
This resulted into this response from Robot Framework which appears to be what you're looking for.
Suite Executor: Robot Framework 3.0 (Python 2.7.9 on win32)
==============================================================================
MyLibrary
==============================================================================
MyLibrary.Test
==============================================================================
A Test Case this is testing
| PASS |
------------------------------------------------------------------------------
MyLibrary.Test | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
MyLibrary | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
这篇关于如何将值从python代码传递给机器人框架的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!