public function __construct($url = 'http://localhost:4444/wd/hub', $desired_capabilities = array())
 {
     $url = preg_replace('#/+$#', '', $url);
     $command = array('url' => $url, 'name' => 'newSession', 'parameters' => array('desiredCapabilities' => $desired_capabilities));
     $response = HttpCommandExecutor::remoteExecute($command);
     $this->executor = new HttpCommandExecutor($url, $response['sessionId']);
 }
Exemplo n.º 2
0
  /**
   * Construct the RemoteWebDriver by a desired capabilities.
   *
   * @param string $url The url of the remote server
   * @param array $desired_capabilities The webdriver desired capabilities
   * @param int $timeout_in_ms
   * @return RemoteWebDriver
   */
  public static function create(
    $url = 'http://localhost:4444/wd/hub',
    $desired_capabilities = array(),
    $timeout_in_ms = 300000
  ) {
    $url = preg_replace('#/+$#', '', $url);
    $command = array(
      'url' => $url,
      'name' => 'newSession',
      'parameters' => array('desiredCapabilities' => $desired_capabilities),
    );
    $response = HttpCommandExecutor::remoteExecute(
      $command,
      array(
        CURLOPT_CONNECTTIMEOUT_MS => $timeout_in_ms,
      )
    );

    $driver = new static();
    $executor = new HttpCommandExecutor(
      $url,
      $response['sessionId']
    );
    return $driver->setCommandExecutor($executor);
  }
 /**
  * @param WebDriverCommand $command
  * @param array $curl_opts
  *
  * @return mixed
  */
 public function execute(WebDriverCommand $command, $curl_opts = array())
 {
     if ($command->getName() === DriverCommand::NEW_SESSION) {
         $this->service->start();
     }
     try {
         $value = parent::execute($command, $curl_opts);
         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;
     }
 }
Exemplo n.º 4
0
 public function execute($command_name, $params = array())
 {
     $command = new WebDriverCommand($this->sessionID, $command_name, $params);
     $response = $this->executor->execute($command);
     return $response->getValue();
 }
Exemplo n.º 5
0
 /**
  * @param int   $timeout_in_ms
  * @param array $command
  * @return array
  */
 public static function remoteExecuteHttpCommand($timeout_in_ms, $command)
 {
     $response = HttpCommandExecutor::remoteExecute($command, array(CURLOPT_CONNECTTIMEOUT_MS => $timeout_in_ms));
     return $response;
 }