getSession()->evaluateScript('return ErrorHandler.get();'); if (is_array($errors) && count($errors) > 0) { $lastError = array_pop($errors); throw new \RuntimeException(sprintf( 'JS error on page "%s". Message "%s", Filename "%s", Line %s', $this->getSession()->getCurrentUrl(), $lastError['message'], $lastError['filename'], $lastError['lineno'] )); } } /** * @AfterScenario * @javascript */ public function clearJsErrors() { $this->getSession()->executeScript('ErrorHandler.clear();'); } }