简体   繁体   English

如何在机器人框架中动态导入变量文件

[英]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.

相关问题 在机器人框架的变量部分动态设置变量 - Dynamically set a variable in variables section of robot framework 如何将变量文件路径传递给位于PYTHONPATH上的Robot Framework? - How to pass a variable file path to Robot Framework located on PYTHONPATH? 如何使用随变量文件传递的额外参数 - 机器人框架 - How to use extra arguments passed with Variable file - Robot framework 如何使报告在机器人框架中动态分类? - How to make reports dynamically categorised in robot framework? 如何在 ROBOT 框架中将响应存储在变量中 - How to store response in variable in ROBOT framework 如何在机器人框架中将变量用作url的一部分 - How to use a variable as part of url in robot framework 如何在 Robot Framework 中设置带有特殊字符的变量 - How to set variable with special characters in Robot Framework 如何在 Robot Framework 中从同一个 python 文件中导入两个不同类的方法? - How to import the methods of two different classes from the same python file in the Robot Framework? 将位于 python 文件中的 python 类中的函数导入机器人框架 - Import functions from python classes located in python file into Robot Framework 从批处理文件运行机器人框架脚本:导入库错误 - Running robot framework scripts from batch file: Import Library Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM