Forum Discussion

VinnyK's avatar
VinnyK
Occasional Contributor
5 years ago

[TestLeft] How to interact with an object that needs scrolling to view (Desktop application)

Hi 

I m currently automating a Desktop application using C# NUnit, TestLeft, most of the objects identified are MSAAObjects.

I want to click on an object which is not visible on screen and I get the following error

SmartBear.TestLeft.TestObjects.InvocationException: 'There was an attempt to perform an action on a zero-sized window.

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

 There is a bit of scrolling involved to get the object visible on screen, so I tried

//obj is of type IMSAAObject

     while (!obj.VisibleOnScreen)

            {

                driver.Desktop.Keys("[Down]");

            } 

But this takes ages to get to that object.

Is there a proper way to scroll to view the object? This is a MSAAObject, so there is no Focus() or ClickItem() options

Any sort of help is appreciated

Thanks in advance

3 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    As a quick idea and assuming that the problematic control resides on some form with scrollbar:

    Try to send .Keys("[PgDown]") not to the desktop, but to the proper scrollbar of the form.

     

    • VinnyK's avatar
      VinnyK
      Occasional Contributor

      Thanks for the response,

       

      I did use the .Keys("[PageDown]") on the scrollbar, it does scroll to display next set of objects. However I was hoping to find a better way to bring the intended object to display by using that object iteslf.

       

      At any given scrolled position I should be able to find that object(that object can be at the top(Up) or bottom(Down) of the form irrespective of the current scrolled position).

       

      For now I am using 

       

      //1019 is the ScreenTop value(position of the indicator) of the scroll indicator when it is scrolled down to maximum

           

           var downMax = false;

                  while (!object.VisibleOnScreen)

                  {

                      if (scrollBarIndicator.ScreenTop < 1019 && !downMax) 

                      {

                          scrollBar.Keys("[PageDown]");

                      }

                      else

                      {

                          down = true;

                          scrollBar.Keys("[PageUp]");

                      }

                   }

       

      This works, but, is there a nicer way to get to the object which is not visible on screen?

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        is there a nicer way to get to the object which is not visible on screen?

        I'm afraid that there is not...

        TestComplete (and TestLeft) can automatically put into view quite a few controls, but not MSAA ones, according to my knowledge.

        For official reply you may ask Support directly via the https://support.smartbear.com/message/?prod=TestLeft form and I will appreciate it if you update this thread in case they provide better solution.