How do I tell Behat / Mink to hover over an element on a webpage?
I figured it out, based on this answer https://stackoverflow.com/a/17217598 and just replaced the click() with mouseOver().
Here is my FeatureContext code:
/**
* @When /^I hover over the element "([^"]*)"$/
*/
public function iHoverOverTheElement($locator)
{
$session = $this->getSession(); // get the mink session
$element = $session->getPage()->find('css', $locator); // runs the actual query and returns the element
// errors must not pass silently
if (null === $element) {
throw new \InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $locator));
}
// ok, let's hover it
$element->mouseOver();
}
I have to pass the css selector when I use it, so usage looks like:
...
When I hover over the element ".about"
...