【问题标题】:Import custom library from a different path in Robot Framework从 Robot Framework 中的不同路径导入自定义库
【发布时间】:2015-09-23 12:27:15
【问题描述】:

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

这是文件夹层次结构:

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

谢谢。

【问题讨论】:

    标签: robotframework


    【解决方案1】:

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

    *** 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 部分下。

    【讨论】:

      猜你喜欢
      • 2020-02-05
      • 2019-01-13
      • 2016-02-16
      • 2015-11-12
      • 2020-03-22
      • 2015-01-06
      • 2017-04-22
      • 2014-03-23
      • 1970-01-01
      相关资源
      最近更新 更多