예제 #1
0
 /**
  * Construct the RemoteWebDriver by a desired capabilities.
  *
  * @param string $url The url of the remote server
  * @param DesiredCapabilities $desired_capabilities The desired capabilities
  * @param int $timeout_in_ms
  * @return RemoteWebDriver
  */
 public static function create($url = 'http://localhost:4444/wd/hub', $desired_capabilities = null, $timeout_in_ms = 300000)
 {
     $url = preg_replace('#/+$#', '', $url);
     // Passing DesiredCapabilities as $desired_capabilities is encourged but
     // array is also accepted for legacy reason.
     if ($desired_capabilities instanceof DesiredCapabilities) {
         $desired_capabilities = $desired_capabilities->toArray();
     }
     $executor = new HttpCommandExecutor($url);
     $executor->setConnectionTimeout($timeout_in_ms);
     $command = new WebDriverCommand(null, DriverCommand::NEW_SESSION, array('desiredCapabilities' => $desired_capabilities));
     $response = $executor->execute($command);
     $driver = new static();
     $driver->setSessionID($response->getSessionID())->setCommandExecutor($executor);
     return $driver;
 }
예제 #2
0
 /**
  * Get all selenium sessions.
  *
  * @param string $url The url of the remote server
  * @param int $timeout_in_ms
  * @return array
  */
 public static function getAllSessions($url = 'http://localhost:4444/wd/hub', $timeout_in_ms = 30000)
 {
     $executor = new HttpCommandExecutor($url);
     $executor->setConnectionTimeout($timeout_in_ms);
     $command = new WebDriverCommand(null, DriverCommand::GET_ALL_SESSIONS, array());
     return $executor->execute($command)->getValue();
 }