Skip to content

Commit ae5df3a

Browse files
committed
Add get all sessions method
1 parent 11c7bc5 commit ae5df3a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/remote/HttpCommandExecutor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class HttpCommandExecutor implements WebDriverCommandExecutor {
2323
* http://code.google.com/p/selenium/wiki/JsonWireProtocol#Command_Reference
2424
*/
2525
protected static $commands = array(
26+
DriverCommand::GET_ALL_SESSIONS => array('method' => 'GET', 'url' => '/sessions'),
2627
DriverCommand::ACCEPT_ALERT => array('method' => 'POST', 'url' => '/session/:sessionId/accept_alert'),
2728
DriverCommand::ADD_COOKIE => array('method' => 'POST', 'url' => '/session/:sessionId/cookie'),
2829
DriverCommand::CLEAR_ELEMENT => array('method' => 'POST', 'url' => '/session/:sessionId/element/:id/clear'),

lib/remote/RemoteWebDriver.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,29 @@ public function getSessionID() {
461461
return $this->sessionID;
462462
}
463463

464+
/**
465+
* Get all selenium sessions.
466+
*
467+
* @param string $url The url of the remote server
468+
* @param int $timeout_in_ms
469+
* @return array
470+
*/
471+
public static function getAllSessions(
472+
$url = 'http://localhost:4444/wd/hub',
473+
$timeout_in_ms = 300000
474+
) {
475+
$executor = new HttpCommandExecutor($url);
476+
$executor->setConnectionTimeout($timeout_in_ms);
477+
478+
$command = new WebDriverCommand(
479+
null,
480+
DriverCommand::GET_ALL_SESSIONS,
481+
array()
482+
);
483+
484+
return $executor->execute($command)->getValue();
485+
}
486+
464487
public function execute($command_name, $params = array()) {
465488
$command = new WebDriverCommand(
466489
$this->sessionID,

0 commit comments

Comments
 (0)