Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import custom library from a different path in Robot Framework

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.

like image 708
PurpleBeni Avatar asked Jul 06 '15 11:07

PurpleBeni


1 Answers

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 Using Test Libraries.

like image 122
Bryan Oakley Avatar answered Sep 28 '22 01:09

Bryan Oakley