Forum Discussion

SmartBST's avatar
SmartBST
Contributor
8 years ago

Best Practice when using a local file for a test case

Hi All,

 

Can anyone recommend a good practice when using local files for a test case, I am currently recording the step where I have to select the file from my local machine as the following

 

Select the ellipse button in my application going to the file explorer and selecting the file

 

 

Thanks

  • SmartBST's avatar
    SmartBST
    8 years ago

    I did not have the open file method, the main issue now is when selecting the pop up menu to open the import screen, the tool is not recognizing the object

  • That may work for you now, but you'll find several threads in this forum that advise against using that sort of positioning in your test.  It is not stable.  If you move to another browser or test machine or even use a different monitor, there is a high risk that your test will break.  Using the object names is the better solution.

  • shankar_r's avatar
    shankar_r
    Community Hero

    Hi, 

     

    You can use the OpenFile method to select a file by its path:

     

    // JScript
    Aliases.browser.dlgopen.OpenFile("C:\\MyFolder\\MyFile.txt");
    var dlg = Sys.Browser("iexplore").Window("#32770", "Choose File to Upload");

    dlg.OpenFile("c:\\temp\\test.txt");

     

  • Is selecting the local file something you are testing or do you need the file as data for your test?

    • SmartBST's avatar
      SmartBST
      Contributor

      I need the file as data for my test. I am uploading a package into our import tool

      • Marsha_R's avatar
        Marsha_R
        Moderator

        So you're testing the upload?

         

        You should be able to select the ellipses button just like you do any other object.  Did you have a problem recording this step?