/**
  * @param       $script
  * @param array $arguments
  * @return mixed
  * @throws WebDriverException
  */
 public function executeScript($script, array $arguments = array()) {
   $this->dispatch('beforeScript', $script, $this);
   try {
     $result = $this->driver->executeScript($script, $arguments);
   } catch (WebDriverException $exception) {
     $this->dispatchOnException($exception);
   }
   $this->dispatch('afterScript', $script, $this);
   return $result;
 }
 /**
  * @param       $script
  * @param array $arguments
  * @return mixed
  * @throws WebDriverException
  */
 public function executeScript($script, array $arguments = array())
 {
     if (!$this->driver instanceof JavaScriptExecutor) {
         throw new UnsupportedOperationException('driver does not implement JavaScriptExecutor');
     }
     $this->dispatch('beforeScript', $script, $this);
     try {
         $result = $this->driver->executeScript($script, $arguments);
     } catch (WebDriverException $exception) {
         $this->dispatchOnException($exception);
     }
     $this->dispatch('afterScript', $script, $this);
     return $result;
 }