cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a TestComplete method from external application

SOLVED
Highlighted
Occasional Contributor

Calling a TestComplete method from external application

Hello,

I have a TestComplete project with a python script, wich is testing an application (Application A).

 My plan is it, to call a function out of the TestComplete testing script from another C# application.

 

C# application (B)                                                     Python TestComplete script             Application A

push button in application A                 --->               pushButton()                --->                *button gets pushed*

 

Is there an elegant way to do this? Like some kind of Interprocess Communication.

I know that there is a REST API, but because both applications run on the same computer this would not be nice solution.

 

I hope you could understand my plan 😄

 

Greetings

 

Leon

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Calling a TestComplete method from external application

Hi Leon,

 

A note for your scheme:

-- TestComplete is essentially Windows application. This means that both TestComplete and Application B must be installed on the same Windows machine.

 

TestComplete does not provide methods like Click(<objectLocator>), but instead it implements the <object>.Click() architecture. I.e. there is no generic Click() method (for example) that can accept some locator, use this locator to get an object and perform click on it. Instead, you must get an object via the means provided by TestComplete and then call .Click() method provided by this object.

 

Now as for existing options - 5 of them exist (check help for more details):

-- Self-tested application;

-- TestComplete as DCOM server;

-- Regular script called via command line;

-- REST API;

-- TestLeft.

 

Four first options require a script that searches for the object and clicks it to be implemented in TestComplete and differ only by the way how this script is called - using OLE, DCOM, command line or REST call.

So, regardless of what option out of four first ones you will choose, you will need to create a required script in TestComplete and call it then via one of the mentioned means.

 

TestLeft is another product provided by SmartBear and is based on TestExecute (which is runtime engine of TestComplete). But in case of TestLeft, you search for the target object and click it not from TestComplete's script, but directly from C#/VB.Net or Java using the wrappers over corresponding methods of TestComplete. I.e. you don't need to create a script in TestComplete, but instead must implement the same functionality (search for the object and click on the found one) in .Net/Java language. (TestLeft is oriented on unit testing and MSTest/NUnit framework, but I hope that it can be used to create a standalone application as well.)

 

Considering all the above and the fact that TestLeft requires separate license while still utilizes the functionality of TestExecute, my preference is to use one of the first four options. I.e. to create a set of required (parameterized) action scripts in TestComplete and call then the required script via OLE/DCOM/command-line.

 

However, I think that it is not a bad idea to examine documentation for TestLeft and maybe you might find it to better suit your needs.

 

What is the reason of why you don't want to have scripts to be created in TestComplete but prefer a separate standalone application?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

6 REPLIES 6
Highlighted
Community Hero

Re: Calling a TestComplete method from external application

Hi Leon,

 

I am not sure that I got your plan with all details, so more detailed use case is appreciated.

From what I got, scenario looks like self-testing application functionality that is now deprecated (but still exists) in TestComplete in favor of Test Left.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Highlighted
Occasional Contributor

Re: Calling a TestComplete method from external application

@AlexKaras 

Basically, my plan is it to push a button/write in a text field etc. in another application, without doing it manually.

 

So I need the other application to do, what I want it to do.

 

Also I don't want to control the push button/write in text field actions via TestComplete, but via a external application.

So that my external application can basically push a button in another application with TestComplete running in the background (TestComplete as a means to an end).

 

leonmoto_1-1604561388900.png

 

I am sorry, if I can not describe my problem properly. My english skills are just the basics 🙂

 

Greetings Leon

Highlighted
Community Hero

Re: Calling a TestComplete method from external application

Hi Leon,

 

A note for your scheme:

-- TestComplete is essentially Windows application. This means that both TestComplete and Application B must be installed on the same Windows machine.

 

TestComplete does not provide methods like Click(<objectLocator>), but instead it implements the <object>.Click() architecture. I.e. there is no generic Click() method (for example) that can accept some locator, use this locator to get an object and perform click on it. Instead, you must get an object via the means provided by TestComplete and then call .Click() method provided by this object.

 

Now as for existing options - 5 of them exist (check help for more details):

-- Self-tested application;

-- TestComplete as DCOM server;

-- Regular script called via command line;

-- REST API;

-- TestLeft.

 

Four first options require a script that searches for the object and clicks it to be implemented in TestComplete and differ only by the way how this script is called - using OLE, DCOM, command line or REST call.

So, regardless of what option out of four first ones you will choose, you will need to create a required script in TestComplete and call it then via one of the mentioned means.

 

TestLeft is another product provided by SmartBear and is based on TestExecute (which is runtime engine of TestComplete). But in case of TestLeft, you search for the target object and click it not from TestComplete's script, but directly from C#/VB.Net or Java using the wrappers over corresponding methods of TestComplete. I.e. you don't need to create a script in TestComplete, but instead must implement the same functionality (search for the object and click on the found one) in .Net/Java language. (TestLeft is oriented on unit testing and MSTest/NUnit framework, but I hope that it can be used to create a standalone application as well.)

 

Considering all the above and the fact that TestLeft requires separate license while still utilizes the functionality of TestExecute, my preference is to use one of the first four options. I.e. to create a set of required (parameterized) action scripts in TestComplete and call then the required script via OLE/DCOM/command-line.

 

However, I think that it is not a bad idea to examine documentation for TestLeft and maybe you might find it to better suit your needs.

 

What is the reason of why you don't want to have scripts to be created in TestComplete but prefer a separate standalone application?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

View solution in original post

Highlighted
Occasional Contributor

Re: Calling a TestComplete method from external application

Thank you very much for the detailed answer. @AlexKaras 

 

I want to test the firmware of an embedded device and to program and transmit parameters to this device, I need some functionality from another application.

So for the beginning, I want to access these funcionality with TestComplete by clicking on certain buttons.

 

I will have a look at all the options you gave me, and I hope I can find a fitting solution for me 🙂

 

Again thank you and greetings from Germany

 

Highlighted
Community Hero

Re: Calling a TestComplete method from external application

Hi Leon,

 

I want to test the firmware of an embedded device and to program and transmit parameters to this device, I need some functionality from another application.

TestComplete is not bound to only one tested application during test run, but it can seamlessly switch from one application to another.

I might be incorrect with my guess as for how your applications are connected and communicate with one another but it is perfectly fine for TestComplete to have test code like this (demo pseudo):

var app1 = Sys.AppToPrepareParams;

var app2 = Sys.AppToProgramEmbeddedDevice;

 

app1.Activate();

app1.MainForm.Button1.Click();

app1.MainForm.Button2.Click();

app1.MainForm.ButtonSendDataToApp2.Click();

 

app2.Activate();

app2.MainForm.ButtonDisplayParams.Click();

app2.MainForm.ButtonProgramDevice.Click();

 

app1.Activate();

...

 

Might this somehow help you?

 

P.S. I am not from Germany but one hour ahead;) though I know several people who are in München now 🙂

 

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Highlighted
Occasional Contributor

Re: Calling a TestComplete method from external application

Hey, it's me again.

 

Just a little update on how things are going (maybe this will help somebody in the future):

 

I went with the COM-Interface approach and it works great for me.

 

I can now start my TestComplete routines from my C# application.

This documentation was very helpful:

https://support.smartbear.com/testcomplete/docs/working-with/automating/via-com/about.html

https://support.smartbear.com/testcomplete/docs/working-with/automating/via-com/calling-script-routi...

 

The only challenge for me, was to create a self-signed certificate for my application. But I got a good explanation under https://www.virtues.it/2015/08/howto-create-selfsigned-certificates-with-makecert/

 

I hope this is goingt to help somebody in the future

 

Again thanks to @AlexKaras 

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors