/** * @Given /^I scroll to the top$/ */ public function iScrollToTheTop() { $driver = $this->getSession()->getDriver(); // Wait two seconds for admin menu if using js. if ($driver instanceof Selenium2Driver) { $element = $driver . findElement(By . id("header")); $actions = new Actions($driver); $actions . moveToElement($element); // actions.click(); $actions . perform(); } }
function findElement($e, $str) { $retval = false; foreach ($e as $k => $v) { if ($k == $str) { $retval = $v; } if (!$retval && is_array($v)) { $retval = findElement($v, $str); } if ($retval != false) { break; } } // end foreach return $retval; }