Forum Discussion
HKosova
Alumni
14 years agoHi Nagesh,
You can access the Project object via COM using the GetObjectByName method of the Integration object. Then, you can add and set project variables like this:
Please note that the COM access to the Project object is available only after the test run was started in TestComplete - therefore, there's the RunTestByName call before GetObjectByName in the script. The reason for this is that a project suite can contain multiple projects, and when no test is running, the Project object doesn't "know" which project to access.
You can access the Project object via COM using the GetObjectByName method of the Integration object. Then, you can add and set project variables like this:
' Switch TestComplete to the playback state
objIntegration.RunTestByName "ProjectName", "Script|Unit1|Main"
' Set project variables
Set objVars = objIntegration.GetObjectByName("Project").Variables
objVars.AddVariable "VarName" , "String"
objVars.VarName = "MyValue"
Please note that the COM access to the Project object is available only after the test run was started in TestComplete - therefore, there's the RunTestByName call before GetObjectByName in the script. The reason for this is that a project suite can contain multiple projects, and when no test is running, the Project object doesn't "know" which project to access.