[英]How to import variable file dynamically in robot framework
I am working in robot framework.我在机器人框架中工作。 I have two variables files in it.
我有两个变量文件。 I want to pass these variables files dynamically.
我想动态传递这些变量文件。 In certain condition I want to send a.py and in others b.py.
在某些情况下,我想发送 a.py,而在其他情况下,我想发送 b.py。 But this information I want to pass dynamically.
但是我想动态传递这些信息。 Can you please help me with this
你能帮我解决这个问题吗
You can use the Import library keyword to manually import an external file.您可以使用Import library关键字手动导入外部文件。
Then use the Run Keyword If keyword to check which library to import.然后使用Run Keyword If关键字检查要导入的库。 For example:
例如:
Run Keyword If '${VAR}' == 'a' Import Library a.py
Run Keyword If '${VAR}' == 'b' Import Library b.py
You can pass the VAR
as a parameter to your test:您可以将
VAR
作为参数传递给您的测试:
pybot --variable VAR:a TestSuite
You can import files based on the variable you are passing during execution您可以根据执行期间传递的变量导入文件
*** Settings ***
Variables config_${TEST_ENVIRONMENT}.yaml
*** Test Cases ***
*** Keywords ***
Robot command to execute:要执行的机器人命令:
$ robot --variable TEST_ENVIRONMENT:local file_name.robot
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.