Ask a Question

Different application filepaths for TestedApps

SOLVED
GradyJr
Contributor

Different application filepaths for TestedApps

Prior to recording keyword tests/scripts on a system, one must identify the application(s) being tested in the TestedApps area and then, in the script, start an application with the TestApps.<appname>.Run (or RunAs) method. In the TestedApps area of TestComplete, the source/filepath of the executable is identified in the "Application:" textbox. All is well and good until I try to run the project on a different system where the TestedApp application/executable has been installed in a totally different filepath.

 

Now, I can certainly create multiple copies of the application in the TestedApps area (with different names such as MyApp1, MyApp2, etc) and then insert IF logic in the test/script that will find the app in the correct location:

 

If Sys.HostName = "ServerA" Then
Call TestedApps.MyApp1.Run(1, True)
ElseIf Sys.HostName = "ServerB" Then
Call TestedApps.MyApp2.Run(1, True)
Else
Call TestedApps.MyApp3.Run(1, True)
End If

 

but that seems like a bulky, convoluted way to handle it. What I envision would be having an optional configuration file associated with the project suite that can be edited on a particular system with that system's correct values which are read in at project suite start up and utilized for the run. Something like:

<TestExecuteConfig>
<TestedApps>
<MyApp>
<FilePath>C:\ProgramFiles\MyApp.exe</FilePath>

<CommandLineParms></CommandLineParms>

<WorkingFolder></WorkingFolder>
<MyApp/>

<AnotherApp>

<FilePath>C:\ProgramFiles\AnotherApp.exe</FilePath>

<CommandLineParms></CommandLineParms>

<WorkingFolder></WorkingFolder>

</AnotherApp>
</TestedApps>
<SomethingElse>
. . . . . . . . . . . . . . . . 
</SomethingElse>
</TestExecuteConfig>

The "Application:" textbox would dynamically be populated with the FilePath value above requiring only one definition of the application in the TestApps area and no IF logic necessary.

Does anything like this exist in TestComplete/TestExecute and, if not, what is the best way to handle it? I searched the Help files within the TestComplete application and this Community Board but didn't really see anything close to this.

4 REPLIES 4
tristaanogre
Esteemed Contributor

There's not EXACTLY a way of importing a TestedApp in like that.  However, a couple of things:

 

1) TestedApps is an object in TestComplete with a method called "Add" where you can add a tested application on the fly.  Sample code is at https://support.smartbear.com/testcomplete/docs/reference/project-objects/items/tested-apps/testedap... along with all sorts of other documentation.
2) TestedApp is an individual item within the TestedApps collection which you can set a number of properties on as well. (https://support.smartbear.com/testcomplete/docs/reference/project-objects/items/tested-apps/testedap...)

3) There is an object called Storages which has an XML capability.  (https://support.smartbear.com/testcomplete/docs/testing-with/advanced/working-with-external-data-sou...

 

Combine these three different pieces and you can write code to do EXACTLY what you want: read configuration information from an XML file into the project and use it to launch your tested application regardless of machine.


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
sonya_m
SmartBear Alumni (Retired)

Thank you tristaanogre.

 

Hi @GradyJr have you tried inplementing the approach above? 


Sonya Mihaljova
Community and Education Specialist

Sorry for not responding sooner.  I was able to accomplish what I needed by using your first suggestion of dynamically adding testedapps on those servers where the applications are installed on a different drive or have any sort of different file path name.  i created index variables for the applications and Initialization and  finalization routines. In the initialization, if it is one of the servers that doesn't conform to the normal naming convention, i add a testedapp and store its index in the variable for that app. if it's not, then I'm using the TestedApps.Find("appname") to get the index. The finalization routine simply deletes any tested apps that had to be added. Thanks again!

sonya_m
SmartBear Alumni (Retired)

Thank you for the update, glad to hear tristaanogre's advice helpedSmiley Happy


Sonya Mihaljova
Community and Education Specialist

cancel
Showing results for 
Search instead for 
Did you mean: