Import custom library from a different path in Robot Framework

ε祈祈猫儿з 提交于 2019-12-10 09:28:00

问题


I have several test files in different folders (for different issues) and I want to use a separate folder that will contain all the Custom Libraries I use. All of the sub folders, including the custom libraries, will be in one master folder. How do I import the test library from the separated folder?

Here is the folder hierarchy:

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

Thank you.


回答1:


There are many ways. For one, just use the path. For example:

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

Or, you can add Test Library/Custom Libraries to your PYTHONPATH variable and just use the library name itself:

*** Settings ***
| Library | customlibrary

Or, you can set a variable that defines the directory -- either in a variables table or from the command line:

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

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

This is all described in the robot framework user guide, under the section Taking test libraries into use



来源:https://stackoverflow.com/questions/31244476/import-custom-library-from-a-different-path-in-robot-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!