Created
April 16, 2015 22:01
-
-
Save MKorostoff/c94824a467ffa53f4fa9 to your computer and use it in GitHub Desktop.
Scroll into view with behat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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
This would be nice as well - for instance scrolling to an anchor tag with linked text.