Reputation: 9711
I do have the following folder structure for python scripts.
From Python I can run a script in folder Feed2Scripts as follows. Can this be possible in Robot Frame Work through imported libraries? > Note that I have common scripts in ‘GeneralScripts’ used by all other scripts in different folders
../Scripts>python –m Feed2Scripts.Script1 param1
If I just import Feed2Scripts/Script1.py
as a library in RF, then It is failing to load libraries defined 'GeneralScripts'
Upvotes: 4
Views: 4242
Reputation: 8484
First you set your python path on RIDE's Tools->Preferences->Importing
Pythonpath
so it does include your library and all its dependencies (imported modules and so on), like this:
(If your library is distributed via PIP, just pip install my_library_package_name
instead, on the same environment you are running Robotframework/RIDE)
Then you can add the library to your test suite on the add library
dialog you can open by pressing the library
button on the Edit
tab you can see when you select the suite:
After that, all keywords defined in your library will be available for use in any test of the test suite. You will see a Library
import sentence on the Settings
section of the header of your suite's code (On your text editor or RIDE's Text Edit
tab of the suite:
Sometimes RIDE doesn't recognize the keywords on a recently added or modified library right away. In that case, Save all
(CTRL+SHIFT+S
) and restart RIDE to fix the issue.
Also, watch out for the library entry showing up in red on the suite import list on RIDE's Edit
tab; it means something went wrong when trying to import the library. If you need to know what, you can find the trace on RIDE's Tools->View Ride Log
.
Upvotes: 3