Forum Discussion

AndrewCast's avatar
AndrewCast
Contributor
6 years ago
Solved

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?

 

  • 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);

     

2 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    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);

     

  • tristaanogre's avatar
    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.