• 1 reply
  • Latest Post - ‏2013-02-28T18:18:40Z by SystemAdmin
16727 Posts

Pinned topic RFT to Open a file from Desktop

‏2013-02-27T19:26:15Z |

We have a particular scenario where the Text file gets saves at a given location (for example on Desktop or in My documents).
Is there a way that RFT after done with playback goes to the specified file location and opens it?
i was trying the below

String sDocPath = "cmd /c\"C:\\Users.....ABC.txt"; //

I just want to open the file from the given location and close it, just to make sure it saved the file.
RFT worker
Updated on 2013-02-28T18:18:40Z at 2013-02-28T18:18:40Z by SystemAdmin
  • SystemAdmin
    16727 Posts

    Re: RFT to Open a file from Desktop

    If you're just looking to verify that the file was saved, why not use the Java File class? Something as simple as:
    File file = new File("C:\\Users\\...ABC.txt");
    if (file.exists() && file.isFile()) {
       // success! file is there!
    } else {
       // failure! file is not there :(

    will let you know whether or not the file was saved. If you always use the same file name and directory path, you'll need to delete the file at the beginning of the script to ensure that the file found by the above code was saved by your script. You can also verify the contents by using a file input stream class like FileReader or FileInputStream to read the contents to a String and perform some comparison against that string.
    Updated on 2014-03-25T12:56:40Z at 2014-03-25T12:56:40Z by iron-man