/**
   * 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);
  }
 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']);
 }
 /**
  * @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;
 }