Forum Discussion

vthomeschoolmom's avatar
vthomeschoolmom
Super Contributor
14 years ago

writing bullet proof portable scripts

I have a script that navigates to a row in a grid using the grid's native properties. The script then calculates the bottom right hand corner and subtracts a bit to determine a clickable place on the grid where there is unlikely to be a different grid context (set of rows or columns) and sends a right click there to the empty grid space. Depending on the size of my VM, or resolution or a series of other factors, the grid might not be visible there.



Is there a way to test for the visibility of an object's coordinates?



Thanks



S

2 Replies

  • karkadil's avatar
    karkadil
    Valued Contributor
    Any onscreen object in TestComplete has 2 properties: Visible and VisibleOnScreen. The 2nd one is exactly what you need.



    However, if you are using grid's native properties, there is a possibility that you'll need to write your own function to determine if an object is visible. What you need is to get screen resolution, size and position of the window and grid, and position of the control you are working with inside grid, and after that you will be able to calculate absolute position of the element on the screen.
  • AlexKaras's avatar
    AlexKaras
    Community Hero
    Hi Lane,



    Another possible approach (depending on the tested control and what you need to do) might be that after the target control is found, the script will not click on it, but just set an input focus to it (obj.SetFocus) and then try to perform an action without using the mouse. E.g. this may be something like obj.SetText = 'some new text' to change the text of the control or obj.Keys('![F10]') to open the context menu. Depending on the control, there is a chance that the latter action will bring the control into view automatically, without any actions from your side.



    P.S. The above approach is similar to the 'blind input' method when you, for example, press Tab key several times to move the focus to the needed (even not visible on the screen) control and then start typing (or sending command shortcuts like Ctrl-C/Ctrl-V) without seen the control on the screen.