Forum Discussion

Veroniquelu's avatar
Veroniquelu
Contributor
10 years ago

How do I find an Object if there's scroll bar involved? And how to Drag and Drop them?

Hi All, 

 

I ran into some issues today. 

 

So assuming the object can be everywhere, it can also be on the next half of the screen and you can only see it when you scroll down. How do I find such object and Drag and Drop it to another object that might be on the other half of the screen? Thank you very much.

  • Hi,

     

    To display the web element that is out of the visible web page borders you may use the ScrollIntoView() native web function.

    E.g.:

    oControl.ScrollIntoView(false)

  • So in order to achive that, I replaced .Drag, Please see the code below:

    function DragToObject(source, destination)
    {
    sDelay = 1000;
    source.ScrollIntoView(false);
    var point1 = source.WindowToScreen(source.Width/2, source.Height/2);
    LLPlayer.MouseDown(MK_LBUTTON, point1.X, point1.Y, sDelay);

    destination.ScrollIntoView(false);
    var point2 = destination.WindowToScreen(destination.Width/2, destination.Height/2);
    LLPlayer.MouseMove(point2.X, point2.Y, sDelay);
    LLPlayer.MouseUp(MK_LBUTTON, point2.X, point2.Y, sDelay);

    }

     

     

    This works for me. Thank you all for being so nice and kind :)

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    To display the web element that is out of the visible web page borders you may use the ScrollIntoView() native web function.

    E.g.:

    oControl.ScrollIntoView(false)

    • Veroniquelu's avatar
      Veroniquelu
      Contributor

      Hi Alex,

       

      I am not quite following. If this object can only be found when it's on the page, How can you use oControl.ScrollIntoView(false) when it's not found?

      • Colin_McCrae's avatar
        Colin_McCrae
        Community Hero

        It's only not visible on screen.

         

        If it's on the page, but out of view, ScrollIntoView, should scroll automatically until the object is visible and usable. I use it frequently.

         

        If that doesn't work, and you're able to map/control the scroll bars, your other option is to use the scrollbar in a loop.

         

        eg:

         

        Loop

        >>> Is object visible?

        >>> No? .... scroll

        >>> Yes? .... end Loop

         

        Type thing.