Forum Discussion

vx's avatar
vx
Occasional Contributor
7 years ago
Solved

How to get 'Files' listed in 'Stores' in project explorer

Hello,

 

My requirement is to click on "Browse" button in my application and upload an image. From my understanding to add files/images from our local system, we have to use "Stores|Files" in testcomplete, where we have to first add the images in 'Files' and use it in script. 

But in project explorer, i can see only "Stores", "Files " are not seen listed under it, so i used this way

 

if (Stores.Exists("Files") || Stores.Create("Files"))
{
Files.Add("C:\\Users\\Public\\Pictures\\Sample Pictures\\Desert.jpg", "Desert");
}

 

When i run this, i am getting runtime error saying "Stores is undefined". Please help me resolve this.

 

And welcome any other approaches/suggestions by which we can add files from local system.

  • Files is an object you need to manually add to the Stores node.  Right click on Stores, select Add -> New Item and select "Files".  You can then use the "Files" object (there's no such thing as the "Stores" object) to add, remove, compare files within your test code.

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Files is an object you need to manually add to the Stores node.  Right click on Stores, select Add -> New Item and select "Files".  You can then use the "Files" object (there's no such thing as the "Stores" object) to add, remove, compare files within your test code.

    • vx's avatar
      vx
      Occasional Contributor

      Thank you tristaanogre!! It worked. 

       

      Can you please tell me how to upload/add an image to the desktop app from testcomplete scripts, i work with Jscript.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Generally speaking, it all depends upon how your app handles uploads... what sort of dialog, etc.

         

        I wouldn't use "Stores | Files" for that... that's if you're going to compare a file that your app generates to a file in stores.  When you add a file to the Files object, you do have an option to included it in the Stores folder of your project, but that simply makes it convenient for you to check in/check out of source control. 

         

        So, let's assume that you do have a file stored in Stores called test.jpg.  It's sitting in a folder that you can access using

         

        Project.Path + 'Stores\\Files\\test.jpg'

        So, whatever your application has as an upload dialog with a text field, that's what you would pass to that text field with either a SetText or a Keys call.