Forum Discussion

Logiv's avatar
4 years ago

Prompt for folder and copy file into it


I have a question that might not be doable with TestComplete..
I have these folders as example:





I need to move some files in one of those folders, depending on user input.

Currently, I created some batch files that prompt for the Number.
I then use that variable inside a batch file to tell the system to copy a file to Test003 as example.

It works OK if I use only the batch files manually. When I integrate those in TestComplete, TestComplete does not wait for the user's answer to continue further (TestComplete doesn't know there is a prompt since I coded it in the batch file).

Can I populate a variable using a prompt within TestComplete, to then pass as a parameter to my batch files?

Or would there be a better, different way of doing so.

I do need this variable in a few places inside my script, it is not used only once (I copy different files at different moment of the script).

I don't know if this makes any sense but if someone has an idea, I am willing to try 🙂 


PS: I prefer keyword Test as I am not very good with scripts, but if I do need a script, I use Python.


4 Replies

  • almost everything that can be done in scripts is theoretically possible in keyword tests using the run code snippet operation. In order to do what you are trying to do (from my understanding), you would use the builtin.inputbox method to prompt the user for the desired folder location.

    then you would use aqfilesystem.copy method

    to copy the file into the designated folder (assigned above using the inputbox method). one of the parameters of aqfilesystem.copy method is target location, so instead of hardcoding that value, you would supply the resulting operation of the builtin.inputbox method in there (so set the inputbox result 'the user input for desired location' as a variable)

      • Logiv's avatar


        I used Justin's approach as I ultimately wanted to get rid of the batch files. This way I can run my test and I don't have to maintain, copy, backup the batch files.

        It worked great, thanks. I was able to create folders, copy files into the user's selected folder, remove the archive bit, overwrite existing files, etc.


        And I used the script method. I was not able to assign my folder number to a variable using the Keyword Test, so at that point I converted to script and it was easy enough that I ended up doing everything in script.


        Thank you so much!! I have fun playing with TestComplete!