Showing results for 
Search instead for 
Did you mean: 

How to access the value of a Project Variable programmatically?


How to access the value of a Project Variable programmatically?

Trying to get an idea for how I can interact with Project Variables. Here is a test script I setup:

def TestVars():
  ProjectSuite.Variables.AddVariable("testVar", "Integer")
  ProjectSuite.Variables.VariableByName["testVar"] = 1234

I have a couple of questions.

The above code creates a "Persistent" variable, how do I programmatically create a "Temporary" one?
Secondly, this script fails on the fourth line with the following error.


Type Error
`IDispatchIndexedPropertWrapper` object is not callable


Any ideas? I want to be able to create and edit and call the value of project variables all within a script.

Community Hero

Re: How to access the value of a Project Variable programmatically?

When you talk "Persistent" versus "Temporary", are you using the TestComplete monikers where a persistent variable preserves the content of the variable between test runs or is it "Persistent" in that TestComplete creates a variable that is always associated with the project?


As for the error... one of the limitations of Python is calling object properties that take a aprameter... you can't do so without using the _getprop_ method (see


However, couple of things about your code:


1) If you want to use a ProjectSuite Variable in your project suite, you don't (and probably shouldn't) add it as part of your automation code.  Consider it the same sort of declaration that you would do if it was a variable in code.  You declare before you use.  So, add your variable to your project suite manually.

2) If you do #1, the you shouldn't have to worry about "VariableByName" at all.  You should be able to get the variable easily just by going 



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

Re: How to access the value of a Project Variable programmatically?

Alrighty, that was it. Thanks again, again!

New Here?
Join us and watch the welcome video:
Script Wanted
Let's start July with new challenges!

Create a script to pass custom command-line arguments as a test parameter for the TechCorner tag!

Will you dare to take the challenge?

Top Kudoed Authors