Forum Discussion

shankar_r's avatar
shankar_r
Community Hero
8 years ago

Is there any way to know TestComplete/TestExecute running in 64 bit or 32 Bit in scripts?

Do we have option in scripts to get TestComplete/TestExecute running in 64 bit or 32 Bit?

 

something like is64Bit()

  • Now, I gotta multiple ways of doing this scenario right. I'm currently having below function.

     

    function is64BitClient()
    {
          var tcprocess = Sys.WaitProcess("Test*te", 0);
          
          if(tcprocess.Exists)
          {
                if(tcprocess.ProcessType == "x64")
                {
                      return true;
                }
                else if(tcprocess.ProcessType == "x86")
                {
                      return false;
                }
                else
                {
                      throw "Not able to grab the process type";
                }
          }
          throw "Not able to find the TestComplete/TestExecute process";   
    }

    Thanks everyone for your insights on this.

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Not sure something like this exists 'out-of-the-box'.

    Quick idea: get Sys.Process('Test*te') process and check its .Path property. If it contains 'x64' then TestComplete/TestExecute is of 64-bit architecture.

    • shankar_r's avatar
      shankar_r
      Community Hero

      Yeah, Currently I'm doing the same way, I will get the ParamStr and checks the TestComplete.exe/TestExecute.exe string then in that string i will be checking whether it has x64 or not.

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Em-m...
      Update: Every process has .ProcessType property, so the check like

      if (x86 == process.ProcessType)

        ...

      seems to be more reliable than launch path parsing.

      • shankar_r's avatar
        shankar_r
        Community Hero

        Here is the code I'm using now to get the is64Bit(),

         

        function is64BitClient()
        {
              var tcprocess = Utils.CreateStubObject();
              
              if(Sys.Process("TestComplete").Exists)
              {
                    tcprocess = Sys.Process("TestComplete");
              }
              else if(Sys.Process("TestExecute").Exists)
              {
                    tcprocess = Sys.Process("TestExecute");     
              }
              
              if(tcprocess.Exists)
              {
                    if(tcprocess.ProcessType == "x64")
                    {
                          return true;
                    }
                    else if(tcprocess.ProcessType == "x86")
                    {
                          return false;
                    }
                    else
                    {
                          throwCustomError("Not able to grab the process type");
                    }
              }
              throwCustomError("Not able to find the TestComplete/TestExecute process");
        }
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Other ways:

    function isTestComplete64Bit() {
    var testrunner = Sys.FindId(Win32API.GetCurrentProcessId());
    return (testrunner.ProcessType == "x64");
    }
    function isTestComplete64Bit() {
      var env = WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%");
      // TC ver < 12 : 
      // var env = Sys.OleObject("WScript.Shell").ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%");
      
      return (env != "x86");
    }

    In Python:

    import sys
    
    def isTestComplete64Bit():
      # http://docs.python.org/library/platform.html#cross-platform
      return sys.maxsize > 2**32 
    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      HKosova:

      > var env = WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%");

      Helen, is it safe to assume that processor architecture always match application's bitness?

       

      shankar_r:

      This piece of code:

            var tcprocess = Utils.CreateStubObject();
           
            if(Sys.Process("TestComplete").Exists)
            {
                  tcprocess = Sys.Process("TestComplete");
            }
            else if(Sys.Process("TestExecute").Exists)
            {
                  tcprocess = Sys.Process("TestExecute");    
            }

      can be replaced with this one (considering the fact that only one instance of TestComplete or TestExecute can exist in the system for the given user at the same time):

            var tcprocess = Sys.WaitProcess("Test*te", 0);

      :)

      • shankar_r's avatar
        shankar_r
        Community Hero

        Now, I gotta multiple ways of doing this scenario right. I'm currently having below function.

         

        function is64BitClient()
        {
              var tcprocess = Sys.WaitProcess("Test*te", 0);
              
              if(tcprocess.Exists)
              {
                    if(tcprocess.ProcessType == "x64")
                    {
                          return true;
                    }
                    else if(tcprocess.ProcessType == "x86")
                    {
                          return false;
                    }
                    else
                    {
                          throw "Not able to grab the process type";
                    }
              }
              throw "Not able to find the TestComplete/TestExecute process";   
        }

        Thanks everyone for your insights on this.