Ask a Question

What are the TestComplete variables?

SOLVED
AndrewCast
Contributor

What are the TestComplete variables?

Hi everyone!

 

Let's say we have this: 

 

Sys.Desktop.KeyDown(0x0D)

 

What would "Desktop" be in this case? What if I want to run it such as:

 

variable = 'Desktop'
Sys.variable.KeyDown(0x0D)

 

When I tried to get the type through Python, it returned Null (literally an empty space). The reason is I add a new build of a software - and it gets named "TestApp_2_4_20_0" and I want to use

 

 

variable = "TestApp_2_4_20_0"

 

 To change quickly.

 

-----------

 

If that isn't possible, is it possible to rename a program added midscript?

 

installer = TestedApps.Add('path\\TestApp_2_4_20_0.exe')
test = TestedApps.Items[installer]
test.Run()

Then the tested app is still named 'TestApp_2_4_20_0', when it would make my life easier if I could rename it.

 

Thoughts?

 

2 REPLIES 2
AlexKaras
Champion Level 2

Hi,

 

> What would "Desktop" be in this case?

Desktop in this case is an object provided by TestComplete. See documentation for more details on it.

 

> To change quickly.

i don't know exact syntax for Python, but all scripting languages have eval()/evaluate() function (or a kind) that accepts a string that must conform to the given script language requirements, evaluates it as a code and returns a result.

So, say, for JScript the code will be like this:

var variable = 'Desktop';

var cmd = 'Sys.' + variable + '.KeyDown(0x0D)';

evaluate(cmd);

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] 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 Champions]
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 Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
tristaanogre
Esteemed Contributor

You can do TestedApps.Add to add a new tested app.  The code you have indicated should work.

 

But honestly, that seems a bit bulky.  If you can run your application at a command line, you should be able to utilize the WshShell.Exec method to execute the command line to run your application without needing to add it to TestedApps.


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
cancel
Showing results for 
Search instead for 
Did you mean: