robotframework 中的 "Run Process open . {filepath}" 未在 Mac 上工作,但“运行 进程 explorer.exe {filepath} 正在 Windows 上工作

"Run Process open . {filepath}" in robotframework is not working on Mac but "Run Process explorer.exe {filepath} is working on Windows

我在 Windows10 和 Mac Sierra/El Capitan 上使用 Robotframework 3.0。我尝试在两个系统上使用 RF 操作系统库中的 "Copy file",但在 Mac 上它不起作用。这是 Mac 上的脚本:

Copy file    Testfiles${/}${file}    ${MyDir}
List Directory    ${MyDir}
Run Process open .  /select,${MyDir}${/}${file}  //open . opens the finder
Sleep   5   
Press Ctrl  NUMPAD5    //Right click on Mac
Sleep   1   
Send Keys   e   

我收到以下错误:

OSError: Cannot run program "open ." (in directory "/Users/rj/PycharmProjects/automation"): error=2, No such file or directory

Windows 上有效的脚本:

Copy file   Testfiles${/}${file}    ${MyDir}
List Directory  ${MyDir}    
Run Process explorer.exe    /select,${MyDir}${/}${file}
Sleep   5   
Press Alt and Function    10  //Right click on Windows  
Sleep   1   
Send Keys   e   

其中:Testfiles 是一个目录,我想将{file} 复制到其他目录{MyDir}。发送密钥,"Press Alt and Function 10"是在我的Java库

上创建的关键字

RF 打开了 Testfiles 目录,但没有 select "file" 进行复制。这种情况仅在 Mac 中发生,而相同的脚本在 Windows 中完美运行。

PS: 我已经根据Windows和Mac更改了{MyDir}的路径。

错误消息(如评论中所报告)准确地告诉您出了什么问题。我将突出显示重要部分:

OSError: Cannot run program "open ." (in directory "/Users/rj/PycharmProjects/automation"): error=2, No such file or directory

请注意,它告诉您它正在尝试 运行 一个名为 open . 的程序("open",后跟一个 space 和一个句点)。 space 分隔格式的机器人关键字在参数之间需要两个或更多 space。由于 "." 是一个参数,因此在 "open" 和 space 之间需要两个 space "."`:

Run Process open  .  /select,${MyDir}${/}${file}  //open . opens the finder
#               ^^ two spaces here