Ask a Question

Is there a way to use a variable in a data driven loop for the file address

llcotton
Occasional Contributor

Is there a way to use a variable in a data driven loop for the file address

I use the  data driven file operation on version 12.4 a lot for testing.  I even create a file from ready api runs and use the contents for further testing. 

The data driven operation requires the file name.  Is there a way to use a variable for the file name?

This hard coded file name makes maintenance a nightmare.  We recently had to move to a new computer and server and all

data driven loops had to be reconnected.

 

Is there a way to set a default file path?

Thank you

2 REPLIES 2
tristaanogre
Esteemed Contributor

What I usually do if I have a file that I need to use in a test, I store it somewhere within the project path.  For example, if my project path is C:\MySource\MyProjects\Project1\ for my Project1.MDS file, any files that I need to use within that project I make sure are somewhere within C:\MySource\MyProjects\Project1.  I can then use Project.ConfigPath in all my automation as a starting point for any files.  So, if I have a file in the Scripts folder of my project, I can call 

 

Project.ConfigPath + '\\Scripts\\MyFile.txt'

and no matter what the root path is, it will always find my file.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Marsha_R
Champion Level 2

Put the file in your TestComplete directory and then use Project Path to get to it.

 

https://support.smartbear.com/testcomplete/docs/reference/project-objects/items/network-suite/task/p...

cancel
Showing results for 
Search instead for 
Did you mean: