Scroll Function?

440 views
Skip to first unread message

David Tran

unread,
Nov 20, 2013, 8:11:15 PM11/20/13
to be...@googlegroups.com
Anyone have a function that allows you to scroll down in a browser or move to the element that is not visible?

Alfred Nutile

unread,
Jan 6, 2014, 8:00:37 AM1/6/14
to be...@googlegroups.com
Looking for this too. 

Vanille

unread,
Jan 13, 2014, 5:50:31 AM1/13/14
to be...@googlegroups.com
I use this function to scroll to an element:

public function scrollIntoView($elementId) {
     $function = <<<JS
(function(){
  var elem = document.getElementById("$elementId");
  elem.scrollIntoView(false);
})()
JS;
    try {
      $this->getSession()->executeScript($function);
    }
    catch(Exception $e) {
      throw new \Exception("ScrollIntoView failed");
    }
  }

The js function "scrollIntoView" takes the parameter "alignWithTop". In my method it is set to false making the element align with the bottom. If you need it to align with the top of the scroll area - then set it to true.
Reply all
Reply to author
Forward
0 new messages