5
votes

I'm quite new with Robot Framework, and I cannot find a way to run a process with arguments on windows. I am quite sure I did not understand the documentation and there is a simple way of doing that though...

Ok, let's say I can start my program using this command:

c:\myappdir>MyApp.exe /I ..\params\myAppParams.bin 

How to do that in RF?

Any kind of help would be appreciated. Thank you very much :)

Edit 1:

Here is a piece of my code:

| *Setting*            | *Value*
| Resource             | compilationResource.robot 
#(Process lib is included in compilationResource)

#I removed the "|" for readability
...
TEST1
...
  ${REPLAYEXEDIR}=  get_replay_exe_dir #from a custom lib included in compilationResource
  ${EXEFULLPATH}= Join Path  ${WORKSPACEDIR}  ${REPLAYEXEDIR}  SDataProc.exe
  Should Exist  ${EXEFULLPATH}
  ${REPLAYLOGPATH}=  Join Path  ${WORKSPACEDIR}  ReplayLog.log
  ${REPLAYFILEPATH}=  Join Path  ${WORKSPACEDIR}  params  params.bin
  Should Exist  ${REPLAYFILEPATH}

  Start Process  ${EXEFULLPATH}  stderr=${REPLAYLOGPATH}  stdout=${REPLAYLOGPATH}  alias=replayjob
  Process Should Be Running  replayjob
  Terminate Process  replayjob                
  Process Should Be Stopped  replayjob

This works. As soon as I try to include the arguments like this:

  Start Process  ${EXEFULLPATH} ${/}I ${REPLAYFILEPATH}  stderr=${REPLAYLOGPATH}  stdout=${REPLAYLOGPATH}  alias=replayjob

I get this error:

WindowsError: [Error 2] The system cannot find the file specified

and this error comes from the start process line.

Let me know if I was unclear or if nmore info is needed. Thank you all for your help on this.

Edit 2: SOLUTION

Each argument must be separated form the other (when not running in shell) with a double space. I was not using double spaces, hence the error.

|  | Start Process | ${EXEFULLPATH} | /I | ${REPLAYFILEPATH} | stderr=${REPLAYLOGPATH} | stdout=${REPLAYLOGPATH} | alias=replayjob
1

1 Answers

5
votes

To launch your program from a Robot Framework Test, use the Process library like:

*** Settings ***
Library  Process

*** Test Cases ***
First test
   Run Process  c:${/}myappdir${/}prog.py  /I  ..\params\myAppParams.bin 
   # and then do some tests....