Siya
Siya

Reputation: 307

Python library files in robot framework

I would like to import all of my python files into Robot framework. Currently, I am referencing the files with their entire paths. Instead of that, is there any way to call all the required files in one line? Perhaps by importing all library paths in Robot framework.

Here is an example...

My python scripts are in these locations..

/user/home/scriptLibrary/sample.py
/user/home/scriptLibrary/sample_1.py

and I want to import all python files in Robot script. I am currently hard coding the entire path in the beginning of the script.

/user/home/scriptLibrary/sample.py
/user/home/scriptLibrary/sample_1.py
.
.
.
/user/home/scriptLibrary/sample_n.py

Upvotes: 0

Views: 2678

Answers (2)

ombre42
ombre42

Reputation: 2384

Consider placing all of these imports in a resource file if they are used together. Then in each suite, you only need to import the resource to import all the libraries.

Upvotes: 0

Bryan Oakley
Bryan Oakley

Reputation: 386342

Robot doesn't support more than one library per line in a Settings table. However, you can create a keyword that loads the libraries, then call the keyword from a suite setup. For example:

*** Settings ***
| Suite Setup | Import all libraries

*** Keywords ***
| Import all libraries
| | Import library | ${CURDIR}/sample.py
| | Import library | ${CURDIR}/sample_1.py
| | Import library | ${CURDIR}/sample_2.py
...
| | Import library | ${CURDIR}/sample_n.py

Upvotes: 0

Related Questions