gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 04:33:09 26 4
gpt4 key购买 nike

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

这是文件夹层次结构:

Test Library
-Test Suite1
-test1.txt
-test2.txt
-Test Suite2
-test3.txt
-Custom Libraries
-customlibrary.py


谢谢。

最佳答案

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

*** Settings ***
| Library | ../Custom Libraries/customlibrary.py


或者,您可以将 Test Library/Custom Libraries添加到PYTHONPATH变量中,而仅使用库名本身:

*** Settings ***
| Library | customlibrary


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

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

*** Settings ***
| Library | ${LIBRARIES}/customlibrary.py


所有这些都在《机器人框架用户指南》的 Using Test Libraries部分下进行了描述。

关于robotframework - 从Robot Framework中的其他路径导入自定义库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31244476/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com