机器人框架:在 Windows 上使用参数启动进程?

问题描述 投票:0回答:2

我对 Robot Framework 还很陌生,我找不到在 Windows 上运行带有参数的进程的方法。我很确定我不理解文档,但有一个简单的方法可以做到这一点......

好吧,假设我可以使用以下命令启动我的程序:

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

如何在 RF 中做到这一点?

任何形式的帮助将不胜感激。 非常感谢:)

编辑1:

这是我的一段代码:

| *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

这有效。一旦我尝试包含这样的论点:

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

我收到此错误:

WindowsError: [错误2]系统找不到指定的文件

这个错误来自启动流程线。

如果我不清楚或需要更多信息,请告诉我。 感谢大家对此的帮助。

编辑2:解决方案

每个参数必须用双空格与其他参数分隔(不在 shell 中运行时)。我没有使用双空格,因此出现错误。

|  | Start Process | ${EXEFULLPATH} | /I | ${REPLAYFILEPATH} | stderr=${REPLAYLOGPATH} | stdout=${REPLAYLOGPATH} | alias=replayjob
robotframework
2个回答
7
投票

要从机器人框架测试启动程序,请使用 Process 库,例如:

*** Settings ***
Library  Process

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

0
投票

运行流程后,如何发送输入并阅读提示。

我的是一个交互式Python工具,我需要输入文本并阅读我的工具给出的提示..使用机器人框架测试什么是最好的

© www.soinside.com 2019 - 2024. All rights reserved.