/** * @param $script * @param array $arguments * @return mixed * @throws WebDriverException */ public function executeAsyncScript($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->executeAsyncScript($script, $arguments); } catch (WebDriverException $exception) { $this->dispatchOnException($exception); } $this->dispatch('afterScript', $script, $this); return $result; }