Running a sample script using Robot Framework

1k views Asked by At

I am fairly new to Robot Framework. I am trying to run the following code using Ride IDE but facing issues. Could someone kindly help me on how to get this done.

Code:

*** Settings ***

*** Variables ***

*** Test Cases ***
Setting Variables
    #| Example of running a python script
    ${result}=    run process | python | C:\Users\name\Desktop\hello.py
    #| | Should be equal as integers | ${result.rc} | 0
    #| | Should be equal as strings    | ${result.stdout} | Hello World

*** Keywords ***
1

There are 1 answers

2
pavelsaman On

I still think you should include more details in your question, namely:

  • the content of hello.py
  • the error message you get

Nevertheless, I think your problem will be somewhere around these:

1/ Your Settings section is empty, but you need Process library in order to execute Run Process keyword.

2/ Your hello.py is wrong, doesn't return and print what you think it does.

3/ You absolute path is wrong, the python file resides somewhere else.

4/ You're missing some modules you need in order to execute RF scripts. Please search on this site, similar question about missing modules has been asked many times.

All in all, the whole runnable example (provided you have all the prerequisites installed) would be:

*** Settings *** 
Library    Process    

*** Test Cases *** 
Setting Variables
    ${result}=    Run Process    python    hello.py
    Should be equal as integers    ${result.rc}    0
    Should be equal as strings    ${result.stdout}    Hello World 

It's a good practice not to use absolute paths, so I refer to hello.py differently. The content of the file is:

hello.py

print('Hello World')