Forum Discussion

loctitekid's avatar
loctitekid
Occasional Contributor
15 years ago

How to know current TC version from script?

I have been using TC for a few years, but I'm sure this question is appropriate to this forum.



I have a team working on a generalized script framework. The framework is used by several teams in different areas of the world, all testing the same application, but different versions of the app, and different business rules.



The framework is written in JScript. It contains many if tests to behave differently based on the app version or the locale. I want to move to the latest version of TC, but I don't want to force all my customers to move right away. Also I'd like to be able to run the framework on different versions of TC for troubleshooting if required.



So I want to be able to say something like



if (TC_Version < 7) {

    DoItTheOldWay();

} else {

    UseNewFeature();

}



Is there a global variable or an easy way to tell?



I thought of finding testcomplete.exe and looking at its app version. I also thought of having my own project suite variable. Is there a better way?

2 Replies

  • Hi Neil,




    Use this code:




        Sys.Process("TestComplete").FileVersionInfo.MajorPart;

        //or

        Sys.OleObject("TestComplete.TestCompleteApplication").Manager.ProductInfo.VersionMajor;

  • loctitekid's avatar
    loctitekid
    Occasional Contributor
    Thanks Alex, works a treat.

    For interest, here is the production code I'll use:



      //TC7 Support...

      var testProcess = Sys.WaitProcess("TestExecute", Glo_SpeedFactor * 500);

      if (testProcess.Exists == false) {

        testProcess = Sys.WaitProcess("TestComplete", Glo_SpeedFactor * 500);

      }

      Glo_TCVersion = testProcess.FileVersionInfo.MajorPart;

      //...TC7 Support