Ask a Question

How do i run a Batch file from testComplete

vikram_u_k
Contributor

How do i run a Batch file from testComplete

Hi,

  I am using TestComplete 11.31 and have found it very useful. Currently i need to send a Commandline/Batch command for a C# executable.

 

Please let us know the Insert New operation corresponding to adding a commandline/batch job execution using the process action ("cmd").

 

regards,

Vikram U

7 REPLIES 7
baxatob
Community Hero

Re: How do i run a Batch file from testComplete

One way is to add your batch file as a TestedApps object and run it:

 

TestedApps.yourBatch.Run()

 

tristaanogre
Community Hero

Re: How do i run a Batch file from testComplete

You could also just fire up a shell and call the Exec method.

 

Sys.OleObject("WScript.Shell").Exec("cmd /c ""C:\MyDir\MyBat.bat""")

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
vikram_u_k
Contributor

Re: How do i run a Batch file from testComplete

Hi Support,

Thank you for the quick response. 

 

I just needed a clarification on this question regards the arguments to be passed for the executable.

 

I have a exe which i call with 2 Arguments( ex:  ABC.exe Param1  Param2). In the TestedApps i note that the ABC.exe is listed with commandline parameters as "Param1 Param2".

 

Is there a way to change/parameterise the second argument alone(Param2)?.

 

Thanks and with regards,

Virkram U

tristaanogre
Community Hero

Re: How do i run a Batch file from testComplete

You should be able to access the parameters using the TestedApps object.  See the reference at https://support.smartbear.com/viewarticle/75248/ for the example.

 

Essentially, you would access the SimpleParams object of your tested app, change the parameter to only include param 2, activate, and then run your app.


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
joseph_michaud
Moderator

Re: How do i run a Batch file from testComplete

Through the TestedAppParams Object you can eventually get to the arguments passed to the executable.

 

-----
Joseph
m_essaid
Valued Contributor

Re: How do i run a Batch file from testComplete

I use cmd alot now, I create environments for my apps.

 

for example :

 

first, I kill all cmd processes

 

then :

 

TestedApps.Add('cmd.exe', 'mylocation\mybatchfile.bat', 1, true, '');

TestedApps.cmd.Run;

 

Then I wait till the end of the batch execution with this wait procedure

 

p := Sys.FindChild('ProcessName', 'cmd');
while p.Exists do
begin
IsClosed:= p.WaitProperty('Exists', False);
if not IsClosed then
Delay(3000, 'I wait for the end of the files copy');
p:= Sys.FindChild('ProcessName', 'cmd');
end;

vikram_u_k
Contributor

Re: How do i run a Batch file from testComplete

Thanks Guys,

  I saw that the approach calls for creating commandlines which create new TestedApps which can be validated early.. user inputs with command arguments can be created in advance,

 

Edit: Is there a specific reason we have debug, profile options?.

 

I got the Results from this Link.. https://support.smartbear.com/viewarticle/70910/

The application "MyTestAndroid\TestedApps\TestedApp.exeArgument1  Argument2" started. 18:22:34 Normal
Application domain created: DefaultDomain 18:22:34 Higher
Thread Create ID: 53324 18:22:34 Higher
Thread Create ID: 58744 18:22:34 Higher
Module Loaded: C:\Windows\assembly\NativeImages_v4.0.30319_32\mscorlib

 

 

Thanks a Lot guys for the Support.Heart

 

cancel
Showing results for 
Search instead for 
Did you mean: