Forum Discussion

hogueybear's avatar
Occasional Contributor
9 years ago

How can I change ProjectSuite.Variables when using testexecute?

We have a large automated test suite that has several ProjectSuite.Variables used throughout it.  We have some TestExecute licenses and we want the developers to run the automations using testexecute before they hand the code off to the QA group.


The developers do not have access to TestComplete, only to TestExecute.


They need to be able to change the values of several of the ProjectSuite.Variables prior to running TestExecute.


Anyone know how to change the values of ProjectSuite.Variables using TestExecute?


5 Replies

  • S_Leonardo's avatar
    Occasional Contributor

    You can use a sheet from an excel document, read it using a DDT object and set the variables you need.

    • joseph_michaud's avatar

      You can also create a User Form in your project to display the ProjectSuite Variables and/or modify them.  You could then display the User Form at the beginning of your tests, or set it up as a separate project in the project suite.

  • baxatob's avatar
    Community Hero

    You can't do it using TestExecute. But you can edit project files (.pjs or .mds), which contain all project suite's and project variables. This files have XML structure and it is easy to parse all required data. Only problem - string variable values are stored in HEX format. So you will need to encode/decode it to/from unicode string. Integers/doubles are stored as is.


    [!!!] You should be VERY CAREFUL with your project file data and fully understand what are you doing on your own risk. [!!!]

  • hogueybear's avatar
    Occasional Contributor

    Some interesting ideas from all!


    What we did in the end is create a test called SetProjectVariables and in it we assigned each of the ProjectSuiteVariables to themself.  So the file might look like this:


    function Test1() {
      ProjectSuite.Variables.Name = ProjectSuite.Variables.Name;
      ProjectSuite.Variables.Path = ProjectSuite.Variables.pathvar;


      Log.Message("ASPName is - " + ProjectSuite.Variables.Name);
      Log.Message("pathvar is - " + ProjectSuite.Variables.Path);


    We added the logging of the values so when somone came to QA and said "it's failing" the first thing we could check is what they set the system wide variables to as that is often the problem.


    Turns out we can open this script file and edit it using UltraEdit.  So the process for someone using TestExecute is to grab the test suite from the repository and then edit the above file using UltraEdit to match their environment, start testexecute, run this file as the first one in the test suite and it works as expected.


    So if I was running TestExcute I would edit the file to look something like this:


    function Test1() {
      ProjectSuite.Variables.Name = "bobs_test_run";
      ProjectSuite.Variables.Path = "c:\tmp\testexcute\bob";


      Log.Message("ASPName is - " + ProjectSuite.Variables.Name);
      Log.Message("pathvar is - " + ProjectSuite.Variables.Path);


    The reason we assign the variable to itself is that makes it work as expected with TestComplete and gives the TestExecute users a place to edit and change the global ProjectSuiteVariables.


    You can add as many ProjectSuiteVariables as you want in TestComplete and add them to this file and the TestExecute users can then change their values as needed.

  • I was able to get around this problem by creating a Userform that would appear at the the beginning of the project run with all the fields that would have to be set and an OK and Cancel button. Once the user enters in the variables, they click OK and the values are saved as ProjectSuite variables for the duration of the test run. I even went a little bit farther and setup field validation and a networked lookup that will login to a database environment and let them select a database to test on.


    By default, the Userforms don't show when you create a new project, you have to right-click on the 'Advanced' folder in your project and add 'Userforms'. It will appear along with the default 'Scripts' and 'Events'.