Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
1 reply Latest Post - ‏2013-02-28T18:18:40Z by SystemAdmin
SystemAdmin
SystemAdmin
16727 Posts
ACCEPTED ANSWER

Pinned topic RFT to Open a file from Desktop

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

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"; //
RationalTestScript.getScreen().inputKeys(sDocPath);

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

    Re: RFT to Open a file from Desktop

    ‏2013-02-28T18:18:40Z  in response to SystemAdmin
    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