Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Robot Framework: Start Process with arguments on Windows?

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
like image 904
joris255 Avatar asked Sep 23 '14 09:09

joris255


People also ask

How do I run a powershell script in Robot Framework?

Robot uses two or more spaces to separate arguments from keywords. You need at least two spaces after Powershell.exe . You should also use a forward slash instead of a backwards slash in the filename, or use a double-backwards-slash since a single slash is an escape character. Save this answer.

How do I run a command in Robot Framework?

Execute command - Executes the command in interactive shell. Get File - Downloads the given file from remote machine to local machine. Put File - Uploads asked file from local to remote machine. write - Writes command into interactive shell and waits for next command!


1 Answers

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....
like image 95
Laurent Bristiel Avatar answered Oct 01 '22 00:10

Laurent Bristiel