[英]Importing custom testing library in Robot Framework
I am writing a custom testing library for Robot Framework
in Python
and I want to import it like this:我正在为
Python
中的Robot Framework
编写一个自定义测试库,我想像这样导入它:
Library CustomLibrary
I put the folder containing the source code on the PYTHONPATH
but I am still getting the error: Importing test library 'CustomLibrary' failed: ImportError: No module named CustomLibrary
我将包含源代码的文件夹放在
PYTHONPATH
上,但仍然出现错误: Importing test library 'CustomLibrary' failed: ImportError: No module named CustomLibrary
The CustomLibrary
class is defined in the __init__.py
file, like in the AppiumLibrary
like this: CustomLibrary
class 在__init__.py
文件中定义,就像在AppiumLibrary
中这样:
from CustomLibrary.keywords import *
class CustomLibrary(_CustomKeywords):
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
How can I solve this problem, so I can import it in Robot Framework?我该如何解决这个问题,以便将其导入 Robot Framework? I want to keep the class definition inside the init file.
我想将 class 定义保留在 init 文件中。
You need to make sure that the folder containing CustomLibrary
is on PYTHONPATH.您需要确保包含
CustomLibrary
的文件夹位于 PYTHONPATH 上。
For example, the following works as expected for me:例如,以下对我来说按预期工作:
Library CustomLibrary
Library CustomLibrary
在测试中导入库robot --pythonpath /tmp example.robot
robot --pythonpath /tmp example.robot
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.