1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace Facebook\WebDriver\Remote\Service;
- use Facebook\WebDriver\Exception\WebDriverException;
- use Facebook\WebDriver\Remote\DriverCommand;
- use Facebook\WebDriver\Remote\HttpCommandExecutor;
- use Facebook\WebDriver\Remote\WebDriverCommand;
- use Facebook\WebDriver\Remote\WebDriverResponse;
- class DriverCommandExecutor extends HttpCommandExecutor
- {
-
- private $service;
- public function __construct(DriverService $service)
- {
- parent::__construct($service->getURL());
- $this->service = $service;
- }
-
- public function execute(WebDriverCommand $command)
- {
- if ($command->getName() === DriverCommand::NEW_SESSION) {
- $this->service->start();
- }
- try {
- $value = parent::execute($command);
- if ($command->getName() === DriverCommand::QUIT) {
- $this->service->stop();
- }
- return $value;
- } catch (\Exception $e) {
- if (!$this->service->isRunning()) {
- throw new WebDriverException('The driver server has died.');
- }
- throw $e;
- }
- }
- }
|