cancel
Showing results for 
Search instead for 
Did you mean: 

Prompt for folder and copy file into it

SOLVED
Highlighted
Contributor

Prompt for folder and copy file into it

Hello,

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

Test002

Test003

 

 

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.


Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Staff

Re: Prompt for folder and copy file into it

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.

https://support.smartbear.com/testcomplete/docs/reference/program-objects/builtin/inputbox.html

then you would use aqfilesystem.copy method https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfilesystem/copyfile.html

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)

Best,
Justin Kim

View solution in original post

4 REPLIES 4
Highlighted
Staff

Re: Prompt for folder and copy file into it

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.

https://support.smartbear.com/testcomplete/docs/reference/program-objects/builtin/inputbox.html

then you would use aqfilesystem.copy method https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfilesystem/copyfile.html

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)

Best,
Justin Kim

View solution in original post

Highlighted
Contributor

Re: Prompt for folder and copy file into it

If you want to stick with the batch script approach you can have your script take the path as an argument and call the script from TestComplete using WshShell.Exec(), passing in the path.

https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/runni...


--------------------
QA Systems Architect
Integrated Control Technology
https://www.ict.co/
Highlighted
Contributor

Re: Prompt for folder and copy file into it

Hello!

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! 

Highlighted
Contributor

Re: Prompt for folder and copy file into it

That's great! Don't forget to mark the solution you went with as the accepted solution 🙂


--------------------
QA Systems Architect
Integrated Control Technology
https://www.ict.co/
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors