Execute Robot Framework from Python and return variables

Hello everybody,

I am using Robot Framework from a Python application. So I am using robot.run to start my Robot. It kind of looks like this:
robotOutput = robot.run("task.robot", variable=variables)

robot.run returns a code that gives me an indicator if the task was successful or not. I would like to know if it is somehow possible to get some variables back from the Robotframe work task into the Python application. Are there any examples of how this could be achieved?

thanks for your help.

I am playing with Listeners. The problem is still to get the variables back to my python program from the Listener.

At the moment I save the variables from the listeners to a file and then let the main program read the variables from the file.

This seems to be not an elegant approach. Has anyone any good suggestions?

Hi Nele,

Well using a file is a valid approach and it’s quite simple, it would be a good idea to clean up the files after reading them by the main application, also using a ram disk might be a good idea to reduce wear and tear on your physical disks (hdd’s or ssd’s?).

There are other options and it really depends on your application how you do it.

  • If your robot is running on the same machine as the main app you could probably make some sort of api call to the main app
  • In my case where the robots are expected to be on a different machine from the main application, so I run a webserver in my main application, I then make a web service call from the listener to the rest webservice running on my main application.

There are probably other options too, i just can’t think of any off the top of my head right now.

Dave.