Showing results for 
Search instead for 
Did you mean: 

Relative Path for files to attach in the script


Relative Path for files to attach in the script

I have a situation wherein i have to add some files as attachments.  My script has to run in different machines and I have to attach txt files, xlfiles word doc, pdf files etc in different sizes from 10 to 50MB.

How can I specify relative path in the script so I dont have to modify the script according to each machine. 

The one option i could think of is store the files in the project folder where i can make it generalised by using path for the file =  project.path.

is there anyother way to do it?

RE: Relative Path for files to attach in the script


I'd recommend keeping all your files in Stores (see the "About Files Collection" help topic) or just in the project suite directory.

If this doesn't suit your needs, keep relative paths to your files in project variables and convert them to absolute paths at run time by using the ExpandFileName method (see the "aqFileSystem.ExpandFileName" help topic). Also, you can store your files in a network share whose path will always be the same on all machines in your network.

TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Community Hero

RE: Relative Path for files to attach in the script

We have several projects that have the same need, where we have CSV files that we use for our data driven testing.  No matter what machine we run them on, we need access.  So, we have a standardized directory structure for each project and for our shared source code.  That directory structure can be referenced, then, using relative pathing within the project using the Project.Path value.

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

RE: Relative Path for files to attach in the script

Thank you very much for all the support...
New Here?
Join us and watch the welcome video: