How to use python within RF


Probably been answered before, im trying to use some python in RF, im using classes within my python file which has some functions within it which take in parameters, however when importing to RF it asks for the parameters on the import, I want to be able to use the functions with differing parameters.
Any help is appreciated

You are probably talking about an IDE question. Who is the entity in “it asks”?

You can see that the way you ask and describe your problem, leeds to other questions (from me) from the users in this forum. To avoid this, and maybe to have a quick answer with the solution, you can:

  • Write a small sample of your classes (probably your Library)
  • Write a small example of how you plan to use it in Robot Framework test
  • Write the errors that possibly exist.

Hi Adam,

There a couple of ways to call python functions from robotframework:

  • The simplest is Evaluate, however if your function is part of a module then you need to specify the module, in your case you say the module needs parameters passed on import, so this might not be the best way for you.

  • the other option is Creating a test library class or module of keywords in python that robotframework can call. The documentation here is pretty good, particularly Providing arguments to libraries provides examples of loading the library with parameters. I also published a small library of keywords using this method here PerfmonLibrary that is a working example, so feel free to copy from that if it helps.

If you’re still stuck post what you’ve tried here and we’ll see if we can spot the issue.



thank you for the help, it seems in my python class I need to add in some code so robot recognises it as and can use it in a robot file – ```

Like that

This section of the user manual will cover your needs:
Robot Framework User Guide