4

I do have the following folder structure for python scripts.

enter image description here

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'

4
  • 1
    Anything you put in PYTHONPATH can be imported into robot. Commented Feb 16, 2017 at 19:37
  • Thanks Bryan, will try that Commented Feb 16, 2017 at 20:25
  • What does "failing to load libraries" mean? Do you get an error when you run your tests? If so, what's the error? Commented Feb 17, 2017 at 13:15
  • its working now after adding the location to PYTHONPATH . Thanks Bryan Commented Feb 17, 2017 at 13:47

1 Answer 1

3

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:

RIDE Preferences - Pythonpath

(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:

RIDE - Add library to test 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:

RIDE test suite Library Import Text Edit Tab

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Be careful of your terminology: robot framework and RIDE are two different things. When you say "Robot Framework's Tools->Preferences->Importing", that's not a robot framework setting, that's a RIDE setting. These instructions only work if you're using RIDE, but won't work if you're using some other editor.
Thanks NotGaeL, As Bryan Mentioned , I'm able to import Library after adding the location to PYTHONPATH
@Bryan Oakley you're right, I edited it to RIDE, which is what I was referring to. Thanks for pointing it out! :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.