Forum Discussion

mbarbworldtrips's avatar
mbarbworldtrips
Contributor
3 years ago

import .csv file into TestComplete

I have a .csv file I need to pull into my Keyword Test. The file is pulled during recording and the data displays correctly. However; the playback fails at this step.

 

tvNamespaceTreeControl ClickItem "|Desktop|This PC|Documents" Clicks the '|Desktop|This PC|Documents' item of the 'tvNamespaceTreeControl' tree.

 

Are there any existing scripts or guidance that would help me pull this file in?

  • Well, I reread some of the online info and retried the process a bit differently than I did before. And it is working very nicely.

  • npaisley's avatar
    npaisley
    3 years ago

    Hi mbarbworldtrips!

     

    Playing back the interaction with an Open File dialog can indeed prove tricky at times. Usually it comes down to the click event on the specific file not working correctly. For this we have a couple of workarounds.

     

    The first is that we actually have a built-in 'openFile' method that can be used on Open File dialogs. Once you have the dialog open you can stop the recording process, grab the object spy and spy the 'File Name' field of the Open File dialog. Once that field is mapped, there is an 'openFile' method that can be used and when selecting this method TC will allow you to specify the file you would like to upload. On playback it will then automatically push your file into the Open File dialog and send.  

     

    A second way to do this is to begin typing the name of your file into the File Name field of the dialog, and select the file with the arrow keys on your keyboard and press enter. 

     

    Both of these processes allow you to avoid clicking on the file itself in the dialog to avoid any issues. 

     

    I hope this helps!

    • mbarbworldtrips's avatar
      mbarbworldtrips
      Contributor

      Our software is able to import a .csv that contains customer information to be used in our approval of travel insurance policies.

      The file contains firstName, lastName, gender, dateOfBirth, coverageBeginDate, coverageEndDate, homeCountry, citizenship and emailAddress. They can be all entered manually, but most all our customers use the file import function. I was trying to emulate that process in TestComplete Keyword recording and playback. Recording works well, but my script doesn't not work to pull the file effectively during playback.

      • npaisley's avatar
        npaisley
        Staff

        Hi mbarbworldtrips!

         

        Playing back the interaction with an Open File dialog can indeed prove tricky at times. Usually it comes down to the click event on the specific file not working correctly. For this we have a couple of workarounds.

         

        The first is that we actually have a built-in 'openFile' method that can be used on Open File dialogs. Once you have the dialog open you can stop the recording process, grab the object spy and spy the 'File Name' field of the Open File dialog. Once that field is mapped, there is an 'openFile' method that can be used and when selecting this method TC will allow you to specify the file you would like to upload. On playback it will then automatically push your file into the Open File dialog and send.  

         

        A second way to do this is to begin typing the name of your file into the File Name field of the dialog, and select the file with the arrow keys on your keyboard and press enter. 

         

        Both of these processes allow you to avoid clicking on the file itself in the dialog to avoid any issues. 

         

        I hope this helps!

  • Thanks Nick. I did find that the Open File and Object Spy concept helped achieve the goal.