Forum Discussion

suzanne_raine's avatar
suzanne_raine
Contributor
10 years ago
Solved

Error: The window size is (0, 0);

Hi,



When I'm getting to my line:



MyControl.Click(), I'm getting this error:



The window size is (0, 0); the screen rectangle: the left top corner is (463, 161), the right bottom corner is (463, 161).



It's in a while loop, and doesn't mind clicking the button the first time just hates it the second time. 



Can anyone help?



Thanks
  • Hi Suzanne,



    Most probably, this means that the initial button was hidden by setting its height and width to zero and a new one was created on its place. Use Object Browser in TestComplete to search for both buttons to check if this my guess is correct.

    If my guess is correct, then either:

    -- talk to your developers and discuss if this is an issue or they generate new buttons for purpose (third, fourth, etc. buttons will be generated on the subsequent loop cycles)

    or:

    -- modify your code so it within each loop iteration (for example) searches for all buttons with the given criteria using FindAllChildren() and then iterate through the returned array to search for the button with the height and width greater than zero.

    Another option: if you are using NameMapping for this button, then you may enable Conditional mode for the button and, in addition to the already used recognition parameters, add the condition that the height (or width) must be greater than zero (see TestComplete's help for the Conditional mode in NameMapping).

8 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Suzanne,



    >  it does generate a new button every time. :(

    Then I would do the following:

    -- Put a breakpoint on the MyControl.Click() line within the loop and run the test;

    -- When TestComplete stops on the breakpoint, open the Evaluate window (Ctrl-F12 or Ctrl-F7 shortcut, depending on the keyboard scheme you are using), enter 'MyControl' into the expression field and press the Evaluate button;

    -- After the expression is evaluated to [object], press the Inspect button and examine .Width and .Height properties. Continue test execution if both of them greater than zero;

    -- If one or both properties are equal to zero, then copy the value of the FullName property and paste it into some editor (e.g. Notepad) for future reference;

    -- Close Evaluate window and, using the Object Spy one, highlight the button that you think the code should work with and check the value of its FullName property;

    -- Compare this value with the one from the editor. I bet they should be different;

    -- If this is the case, then click the Highlight Object in the Object Tree button in the Object Spy to navigate to the highlighted button in the object tree;

    -- Not far from there, there should be one more button with the full name equal to the one from the editor. Try to find this button and either analyze why test code found it or show this to the developer and ask him/her why one more button has appeared and why the previous one was hidden.





    > So I guess I'll try this FindAllChildren() method.

    Just in case, the untested sample VBScript pseudo-code:

    Do

      arr = ParentObject.FindAllChildren(...)

      For i = BuiltIn.VarArrayLowBound(arr, 1) To BuiltIn.VarArrayHighBound(arr, 1)

        Set bMyControl= arr(i)

        If ((MyControl.Height > 0) And (MyControl.Width > 0)) Then

          Exit For

        End If

      Next



      If ((0 = bMyControlHeight) Or (0 = bMyControlWidth)) Then

        Call Log.Error("Visible button was not found")

      Else

        MyControl.Click

      End If

      ...

    Loop While ...
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Suzanne,



    Most probably, this means that the initial button was hidden by setting its height and width to zero and a new one was created on its place. Use Object Browser in TestComplete to search for both buttons to check if this my guess is correct.

    If my guess is correct, then either:

    -- talk to your developers and discuss if this is an issue or they generate new buttons for purpose (third, fourth, etc. buttons will be generated on the subsequent loop cycles)

    or:

    -- modify your code so it within each loop iteration (for example) searches for all buttons with the given criteria using FindAllChildren() and then iterate through the returned array to search for the button with the height and width greater than zero.

    Another option: if you are using NameMapping for this button, then you may enable Conditional mode for the button and, in addition to the already used recognition parameters, add the condition that the height (or width) must be greater than zero (see TestComplete's help for the Conditional mode in NameMapping).
  • Thanks for the reply Alex!



    I tried using conditiona mapping, but this time round the error came up as "object does not exist."



    I'm working on modifiying my code but if I'm honest, I'm not really sure how to try your second suggestion. My ability.... to deal with arrays is somewhat bad :P 



    I'll  speak to the developers! 
  • Hi Alex, 



    So I've spoken to the developer and he says that it does generate a new button every time. :(



    So I guess I'll try this FindAllChildren() method. Would you be able to talk me through it? (I'm very new to this!)
  • Hi Alex,



    Thanks ever so much for helping me out! I'm looking at it now, and hopefully it will work! I appreciate the time you took to reply to me.



    Thanks again!
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Oh...



    > he says that it does generate a new button every time. :(

    Only now I noted that developer confirmed that the new button is generated every time.

    In this case, Suzanne, you should stick to the second approach that uses FindAllChildren() as the first approach was a description of the debugging technique when the test works with the object other than expected.



    One more possible approach in case you are using NameMapping for this button is to specify exact Width and Height as the additional recognition parameters. Note, that this will work only if the values of Width and Height are always the same.

    If the values may be different (e.g. for different screen resolutions), than you may switch NameMapping recognition for this button to the Conditional mode where it will be possible to specify that Width and Height  must be greater than some (minimal) value.



    P.S. All the above are a kind of workarounds to make your test code not failing. However, personally I would first talk to developers and ask for the real reason to generate the new button every time. From your description this sounds like waste of computer resources when, actually, the memory leak occurs for every iteration.
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3


    [grunting of an old man]

    I like modern web-developing techniques when it is quite acceptable for the browser to consume up to 0.5 GB of memory and up to 50% of CPU to do the actions and display the contents that the end-user actually never asked for...

    In an old times of the native OS programming, when a resource leak in the application was detected, it was fixed.

    Now the common answer is like 'We are using ZZZ, YYY and ten other js libraries which are very popular and resources are not a problem for us - user can always restart his browser'...

    :(

    Sigh...