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

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

I'm using Robotframework 3.0 on Windows10 and Mac Sierra/El Capitan. I tried to use the "Copy file" from the OperatingSystem Library of RF on both the systems but on Mac it is not working. Here is the script on 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   

I get the following error:

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

Script on Windows which works:

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   

Where: Testfiles is a directory and I want to copy the {file} to other directory {MyDir}. Send keys, "Press Alt and Function 10" are the keywords created on my Java library

The RF opens up the Testfiles directory but doesn't select the "file" to copy. This scenario happens only in Mac and the same scripts works perfectly on Windows.

PS: I've changed the path of {MyDir} according to Windows and Mac.

1 Answer

  1. Oliver- Reply

    2019-11-14

    The error message (as reported in the comments) is telling you exactly what is wrong. I'll highlight the important part:

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

    Notice that it is telling you it is trying to run a program named open . ("open", followed by a single space and a period). Robot keywords in the space-separated format need two or more spaces between arguments. Since "." is an argument, you need two spaces between "open" and "."`:

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

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>