Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dinamic/b5a965788372084df9eb8740b6d9f83b to your computer and use it in GitHub Desktop.
Save dinamic/b5a965788372084df9eb8740b6d9f83b to your computer and use it in GitHub Desktop.
Scroll into view with behat
/**
* @When I scroll :elementId into view
*/
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");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment