从Robot Framework中的其他路径导入自定义库

Pur*_*eni 4 robotframework

我在不同的文件夹中有几个测试文件(针对不同的问题),我想使用一个单独的文件夹,其中包含我使用的所有自定义库.所有子文件夹(包括自定义库)都将位于一个主文件夹中.如何从分隔的文件夹导入测试库?

这是文件夹层次结构:

Test Library
        -Test Suite1
                  -test1.txt
                  -test2.txt
        -Test Suite2
                  -test3.txt
        -Custom Libraries   
                  -customlibrary.py 
Run Code Online (Sandbox Code Playgroud)

谢谢.

Bry*_*ley 13

有很多方法.首先,只需使用路径.例如:

*** Settings ***
| Library | ../Custom Libraries/customlibrary.py
Run Code Online (Sandbox Code Playgroud)

或者,您可以添加Test Library/Custom Libraries到PYTHONPATH变量并只使用库名称本身:

*** Settings ***
| Library | customlibrary
Run Code Online (Sandbox Code Playgroud)

或者,您可以设置一个定义目录的变量 - 在变量表中或从命令行:

*** Variables ***
| ${LIBRARIES} | Test Library/Custom Libraries

*** Settings ***
| Library | ${LIBRARIES}/customlibrary.py
Run Code Online (Sandbox Code Playgroud)

这在机器人框架用户指南的"使测试库使用 "一节中有所描述