Forum Discussion

Sariali's avatar
Sariali
Contributor
14 years ago

Project: Standalone Object Spy

Hi, this thread is not really out of topic. although... i need a help in windows-architecture. ok, first take a look at the problem: we are using different OS in a virtual environment. the dilema is that some of the controls are not named in the same way as in my development OS Win7. in the fact that it is not possilbe to run testComplete in vm I need a possibilty to find out how the controls are named. so I started to write a little tool to do this work. unfortunately I don't know why the function "ToTheTop" in my source don't throw out the name of the buttons. 



I hope there is a beeing in the wide wide world of my internal net to give me a hint. thank you! :)







 

  • Hi Necip,





    As I understand, you need to get objects tree from a machine where TestComplete is not installed. If so, note that you can install TestExecute on that machine and use the following routine to get the objects tree and the properties you need:







    Sub LogAppStructure(obj)

      Err.Clear

      On Error Resume Next





      Dim count, i, Str

      

      ReDim params(7) 

      params(0) = "WndClass"

      params(1) = "WndCaption"

      params(2) = "Index"

      params(3) = "Visible"

      params(4) = "Exists"

      params(5) = "ClrFullClassName"

      params(6) = "ProductName"

      params(7) = "ProductVersion"  

      

      Str = ""

      For i = 0 To UBound(params)

        If IsSupported(obj, params(i)) Then

          Str = Str & params(i) & " = " & VarToStr(Eval("obj." & params(i))) & VbCrLf

        End If

      Next

      

      Call Log.AppendFolder(obj.Name, Str)

      For i = 0 To obj.ChildCount - 1

        Call LogAppStructure(obj.Child(i))

      Next

      Log.PopLogFolder





      On Error GoTo 0

    End Sub









    function LogAppStructure(obj)

    {

      var count, i, Str;

      

      var params = new Array();

      params.push("WndClass");

      params.push("WndCaption");

      params.push("Index");

      params.push("VisibleOnScreen");

      params.push("Exists");

      params.push("Visible");

      params.push("FullName");

      params.push("ClrFullClassName");

      

      Str = "";

      for (var i = 0; i < params.length; i++) {

        if (IsSupported(obj, params))

          Str += params + " = " + VarToStr(eval("obj." + params)) + "\r\n";

      }

      

      Log.AppendFolder(obj.Name, Str);

      for (var i = 0; i < obj.ChildCount; i++) {

        LogAppStructure(obj.Child(i));

      }

      Log.PopLogFolder();

    }







    To use the routine, insert the following routine call somewhere in your test (change the process name):

    LogAppStructure(Sys.Process("MyProcessName")) // or  LogAppStructure(Aliases.MyProcess))


  • Hi Allen, your script works fine!  






    procedure LogAppStructure(obj);

    var count, i, Str;

        params: array[0..7] of string;

    begin  

      params[0] := 'WndClass'; 

      params[1] := 'WndCaption'; 

      params[2] := 'Index'; 

      params[3] := 'Visible'; 

      params[4] := 'Exists'; 

      params[5] := 'ClrFullClassName'; 

      params[6] := 'ProductName'; 

      params[7] := 'ProductVersion';   

       

      Str := ''; 

      for i := 0 To 7 do 

        if IsSupported(obj, params) then 

          Str := Str + params + ' = ' + VarToStr(Evaluate('obj.' + params)) + #10#13; 

       

      Log.AppendFolder(obj.Name, Str); 

      for i := 0 To obj.ChildCount - 1 do 

        LogAppStructure(obj.Child(i)); 

       

      Log.PopLogFolder; 

    end;






    the non-unique vcl-objects are e.g. OpenDialog (window('#32770')

    so i have just call 

      LogAppStructure(Sys.Process('DiaShow').Window('#32770', '*', 1));

    to get only the children of this dialog!



    thank you!