简体   繁体   English

机器人框架中的Python库文件

[英]Python library files in robot framework

I would like to import all of my python files into Robot framework. 我想将我所有的python文件导入到Robot框架中。 Currently, I am referencing the files with their entire paths. 目前,我正在引用文件及其完整路径。 Instead of that, is there any way to call all the required files in one line? 取而代之的是,有什么方法可以在一行中调用所有必需的文件吗? Perhaps by importing all library paths in Robot framework. 也许通过将所有库路径导入到Robot框架中。

Here is an example... 这是一个例子

My python scripts are in these locations.. 我的python脚本在这些位置。

/user/home/scriptLibrary/sample.py
/user/home/scriptLibrary/sample_1.py

and I want to import all python files in Robot script. 我想在机器人脚本中导入所有python文件。 I am currently hard coding the entire path in the beginning of the script. 我目前正在脚本开头对整个路径进行硬编码。

/user/home/scriptLibrary/sample.py
/user/home/scriptLibrary/sample_1.py
.
.
.
/user/home/scriptLibrary/sample_n.py

Robot doesn't support more than one library per line in a Settings table. Robot在“设置”表中每行最多支持一个库。 However, you can create a keyword that loads the libraries, then call the keyword from a suite setup. 但是,您可以创建一个用于加载库的关键字,然后从套件设置中调用该关键字。 For example: 例如:

*** Settings ***
| Suite Setup | Import all libraries

*** Keywords ***
| Import all libraries
| | Import library | ${CURDIR}/sample.py
| | Import library | ${CURDIR}/sample_1.py
| | Import library | ${CURDIR}/sample_2.py
...
| | Import library | ${CURDIR}/sample_n.py

Consider placing all of these imports in a resource file if they are used together. 如果将所有这些导入一起使用,请考虑将它们全部放入资源文件中。 Then in each suite, you only need to import the resource to import all the libraries. 然后,在每个套件中,您只需要导入资源即可导入所有库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM