/**
  * @param WebDriver $driver
  * @param WebDriverDispatcher $dispatcher
  */
 public function __construct(WebDriver $driver, WebDriverDispatcher $dispatcher = null)
 {
     $this->dispatcher = $dispatcher ?: new WebDriverDispatcher();
     if (!$this->dispatcher->getDefaultDriver()) {
         $this->dispatcher->setDefaultDriver($this);
     }
     $this->driver = $driver;
     return $this;
 }
 private function dispatchOnException($exception) {
   $this->dispatch(
     'onException',
     $exception,
     $this->dispatcher->getDefaultDriver()
   );
   throw $exception;
 }