Forum Discussion

Feroz's avatar
Feroz
Occasional Contributor
7 years ago

Unable to use my data driven tests on multiple machines.(How can i make the path of .csv filegeneric

Hi,

I am unable to run my data driven tests on Virtual machine. Since, i created tests earlier on my local machine. The path of .CSV file i am using is pointing to my local machine. How can i make path of the .csv file as more generic. So, that tests can be run on any machine regardless of the path.

 

I am using keyword tests and using Data Driven Loop i have created the tests.

 

Thanks in Advance.

 

Regards,

Feroz

4 Replies

  • Hi Feroz,

     

    Keep the file in the project location and get the complete path.

    Consider the following VBScript code. Call it in you keyword and pass the result to your DataDriven operation. 

    Function GetCompleteFilePath(FileName)
      GetCompleteFilePath = Project.path & FileName
    End Function


    However I am not sure if you would be able to use file rows/colums to iterate your set of operations. If that is the case, you might have to implement your own data driven loop script using VB excel object(in my case) instead of TC's inbuilt Data Driven operation. That is always a better choice.

     

    Regards

    Osaid Ahmad

    • Feroz's avatar
      Feroz
      Occasional Contributor

      Thanks Ahmad i will give it a try.

       

      Regards,

      Feroz

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        A general best practice in working with files like CSV, Excel, or otherwise that are not natively part of TestComplete is to place them somewhere in the descendent path of your project and then  use the methodology that osaid_ahmad mentions in your reference to that file.  The way, no matter what environment you move your tests to, the file will always be accessible to your test cases.  I would even go so far as to recognize those files, especially if they are part of a data driven loop, as "versioned" files that need to be included in your source control solution.