Forum Discussion

liangn's avatar
liangn
Occasional Contributor
15 years ago

Window is not recognized because x.ChildCount wrong

Hello,



in Debugger the x.ChildCount was 8 but in Object Browser it is 11. Why was it not updated correctly. Is there a delay that lets the ChildCount is not updated immediatly? How Can I get the correct ChildCount on time?



Thanks

Nan

6 Replies

  • liangn's avatar
    liangn
    Occasional Contributor
    Hi Allen,



    thank you. It works.



    Best wishes

    Nan
  • -Pv-'s avatar
    -Pv-
    Occasional Contributor
    TC Enterprise 8.2 on Win7x64.

    ChildCount is not always successful for me even after refresh on QWidget controls:



    Object Browser:

    Sys.Process("NAME").Form("License Wizard"):

    ChildCount = 6



    Children displayed:

     Window("QWidget", "", 1)

     Window("QWidget", "", 2)

     MenuBar("System")

     TitleBar(0)

     Client("LicenceWizard")

     Client(0)



    In script

    Sys.Process("NAME").Form("License Wizard").Refresh();

    Log.Message("Searching " + Sys.Process("NAME").Form("License Wizard").ChildCount + " children...");

      for (var i = 0; i < Sys.Process("NAME").Form("License Wizard").ChildCount; i++)

      {

        var MyItem = Sys.Process("NAME").Form("License Wizard").Child(i);

        Log.Message("Searching Item: '" + MyItem.Name + "'");

      }



    Result:

    Searching 4 children...

    Searching Item: 'Client(0)'

    Searching Item: 'Client("License Wizard")'

    Searching Item: 'TitleBar(0)'

    Searching Item: 'MenuBar("System")'



    The control I want to click is in "Window("QWidget", "", 2)"

    Note: the index may change to protect the innocent...



    If I run this code multiple times, there is a random chance the window with the control I want will show up as one of the 4 detected children.

    Very occasionally, 6 children will be reported and the control will be found.



    -Pv-

  • Hi Paul,





    As I understand, you launch the script right after observing the 6 objects in the Object Browser's tree. Will the behavior persist if you comment out the Refresh method call in your code?


  • -Pv-'s avatar
    -Pv-
    Occasional Contributor
    The Object Browser always reports 6 children on Sys.Process("NAME").Form("License Wizard") in the property display.

    The object browser will display the 6 children only after many refreshes.



    Using refresh in script, I get 6 rarely, but only after many refreshes.



    TC cannot click on the required object because is is not always available even though it's clickable on the screen.

    -Pv-
  • Hi Paul,



    We need to reproduce the problem on our side in order to investigate it. So, we need to have your tested application here. Please contact us via our Contact Support form regarding possible options.