Forum Discussion

tnguyen1's avatar
tnguyen1
Occasional Contributor
9 years ago

If Object operation shows field exist but in reality it is not on the screen

I looked through the community posts but couldn't find anything similar to this issue.

 

My keyword test is failing with 'The window size is (0, 0); the screen rectangle: the left top corner is (2, 79), the right bottom corner is (2,79).'  If I understand this correctly, the reason for this error is because it is looking for the field that I've recorded but that field is not there or not visible.  The culprit of this error is the first line says if object exist, then proceed to the next task.  Else, move onto next operation.  I would expect this operation to move onto the next operation because the object really does not exist on the screen.  Instead, it attempts to perform the next task under this operation as if it sees that the object exists.  When I highlight the object, it says 'Cannot highlight this object on screen.'  I'm at a lost on how to fix this issue as I'm not able to see the object in the object browser since it does not exist as expected.  Anyone else seen this issue?  I am using TC10.  Attached are screenshots to show what I'm describing.

 

Thank you,

Tam

12 Replies

  • dmiscannon's avatar
    dmiscannon
    Frequent Contributor

    An object can exist but not be visible on screen. Instead of using if object exists, try using if object is visible and see if that works.

    • Ravik's avatar
      Ravik
      Super Contributor

      Try below methods , it may help you -

       

       

      VisibleOnScreenSpecifies whether any part of the object is currently visible on screen.

       

       It will return boolean value

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi Tam,

     

    As the message in the log says, the object exists but has zero size. As the object exists, it is possible get/set its properties, pass it as a parameter to other functions and do everything else except UI interaction. It is not possible to interact with this object because it is of zero size and thus you (and likewise test code) cannot click or drag it.

    Unfortunately (from the testing point of view), this is pretty common development practice to return everything possible from the web server to the web client and then show or hide some parts of UI interface using jscript processing on the client.

    To add more complexity, UI elements on the client can be hidden by setting their size to zero, moving them far away from the browser viewport, applying css or styles, etc. Additionally, the above actions can be applied by developers not to the given UI element, but to one of its parents (div, panel, etc.). This will result that the UI element that seems must to be visible in the Object Browser is not visible because one of its parents is hidden.

    As it was adviced, you may try to use Visible or VisibleOnScreen property but remember that they might not work as expected if the target UI element is located on the part of the page that is not now visible in the browser window (i.e. the browser window must be scrolled).

    I would recommend to use some additional criteria to figure out if the given UI element must be visible on screen, then use its ScrollIntoView() method to move it into current viewport and then check if it is actually visible on the screen.

    • tnguyen1's avatar
      tnguyen1
      Occasional Contributor

      Thank you everyone for your suggestions and advice, I really appreciate all your feedback.  This issue is no longer an issue for me.  Maybe it wasn't very clear in one of my messages above, but I did end up adding in the VisibleOnScreen property which did fix my issue:

       

      I ended up adding in another If..Then to say if field is VisibleonScreen = True, then run the next task.  This seemed to have fixed the problem.

       

      When I first posted the issue, it didn't occur on me that the object existed with zero size because the UI element is hidden.  It wasn't until I read a different post that talked about Visible and VisibleOnScreen property that sparked the light bulb to check those values.  I'm still learning and again, do appreciate the feedback from everyone who has responded with suggestions.  

      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        Yep.

         

        Developers seems to have numerous different ways of making objects hidden & visible.

         

        Using VisibileOnScreen is usually OK. But I've run into some styling in a Delphi app (desktop app so maybe not of much interest to you) where VisibleOnScreen is TRUE (as is Visible) and yet the object is not visible. (I have no idea how they are hiding it - it is still there in the object model, I've checked) For these, I have to use a "Field" rather than a "Property" of the object. Using the field "FVisible" is the only accurate reflection of it's visibility. (Size remains unchanged throughout)

         

        Another one for the pile of "how are yhou hiding this element?" questions ..... :smileyvery-happy:

    • tnguyen1's avatar
      tnguyen1
      Occasional Contributor

      Thanks for your suggestion djadhav. 

       

      The issue isn't that the script is getting stopped due to a field not being present from delay/wait time, but it that my script was failing because TC sees the field as being present but the field is actually not visible on screen.  I ended up adding in another If..Then to say if field is VisibleonScreen = True, then run the next task.  This seemed to have fixed the problem.

      • djadhav's avatar
        djadhav
        Regular Contributor

        Please post a screenshot of the object properties after selecting the checkbox with the object spy.