Created
August 17, 2013 04:15
-
-
Save delphian/6255239 to your computer and use it in GitHub Desktop.
A replacement for mink's NodeElement mouseOver method. Occationally the mouseOver method will not cause the desired effect (such as when custom javascript is watching for a change of rate in the mouse location before popping up a menu item).
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
/** | |
* More reliable way to hover over an element. Talk to selenium directly. | |
* | |
* @param string $selector | |
* CSS selector. | |
* @param int $sleep | |
* Number of seconds to sleep after hover is initiated. Allows some | |
* slower third party javascript to do its thing before moving on | |
* with more test steps. | |
* | |
* @see https://code.google.com/p/selenium/wiki/JsonWireProtocol | |
* @see https://github.com/facebook/php-webdriver | |
*/ | |
protected function mouseOver($selector, $sleep = 0) | |
{ | |
// This returns a WebDriver\Session instance. | |
$driverSession = $this->getSession()->getDriver()->getWebDriverSession(); | |
$element = $driverSession->element('css selector', $selector); | |
$driverSession->moveto(array('element' => $element->getID())); | |
// Allow any slow javascript to do its thing. | |
if ($sleep) { | |
sleep($sleep); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Specifically NodeElement::mouseOver() would not cause the desired effect when working with the jQuery plugin hoverIntent (https://github.com/briancherne/jquery-hoverIntent)