Shinu John
Shinu John

Reputation: 13

Unable to run shell script from test case

I'm trying to invoke a shell scrip from within a .robot test case. The .sh file is in the same folder as the .robot file

*** Settings ***
Library   Process

*** Test cases ***
Run the shell script
    Start Process ./getIDfromDB.sh  shell=yes

I'm getting the error:

Setting variable 'Start Process ./getIDfromDB.sh' failed: Invalid variable name 'Start Process ./getIDfromDB.sh'.

Running on Ubuntu

Researched documentation for Robot framework but could not find a solution. Maybe digging in the wrong spot.

Upvotes: 0

Views: 1732

Answers (2)

drFunJohn
drFunJohn

Reputation: 319

According error details the keyword is not recognized, I think, you need add extra spaces after keyword name:

    Start Process    ./getIDfromDB.sh     shell=yes

Upvotes: 0

Sameem
Sameem

Reputation: 849

I'm not sure how you are trying to set the path of the shell script in the robot file. The error message seems to convey that something is wrong with the way you're initialising the variable to hold the path.

The following code should work:

*** Settings ***
Library Process

*** Variables ***
${pathToScript}    ./getIDfromDB.sh

*** Test cases ***
Run shell script
    ${output}    Run process    ${pathToScript}        shell=yes

The return code and the output displayed in the terminal are stored in the ${output} variable. You can access the details as ${output.rc} and ${output.stdout} respectively.

You can find more details about the result object here.

Upvotes: 1

Related Questions