I appreciate this question is 4 years old with an accepted answer but your example uses a phrase to identify which element to hover over rather than a CSS selector. I think is a good thing as I like my Behat scripts to be readable by the client and non-technical members of the project team.
So if I may offer an alternative answer:
The script:
...
When I hover over the "About" link
...
The step definition in your FeatureContext:
/**
* @Then I hover over the :phrase link
*/
public function iHoverOverLink($phrase)
{
$session = $this->getSession();
// Get all link elements on the page
$links = $session->getPage()->findAll('css', 'a');
foreach($links as $link) {
if ($link->getText() == $phrase) {
// ok, let's hover it
return $link->mouseOver();
}
}
throw new \InvalidArgumentException(sprintf('Could not find anchor element matching "%s"', $phrase));
}
My example narrows the targetable items down to only anchor elements for speed and efficiency but if you did have non-clickable items in your navigation menu that you wanted to hover over then you could easily remove the word " link" from the end of the step template and change the CSS selector to match all text elements p, span, li, a
.