Source for file remote-control.php
Documentation is available at remote-control.php
* Based on the Domain51_Testing_Selenium class available at
* http://domain51.googlecode.com/svn/Domain51/trunk/
* @author Travis Swicegood <development [at] domain51 [dot] com>
private $_browserUrl =
'';
private $_host =
'localhost';
private $_timeout =
30000;
private $_sessionId =
null;
private $_commandMap =
array(
public function __construct($browser, $browserUrl, $host =
'localhost', $port =
4444, $timeout =
30000) {
$this->_browser =
$browser;
$this->_browserUrl =
$browserUrl;
$this->_timeout =
$timeout;
public function start() {
$response =
$this->cmd('getNewBrowserSession', array($this->_browser, $this->_browserUrl));
$this->cmd('testComplete');
$this->_sessionId =
null;
public function __call($method, $arguments) {
$response =
$this->cmd($method, $arguments);
foreach ($this->_commandMap as $type =>
$commands) {
return substr($response, 0, 2) ==
'OK' ?
true :
false;
private function _server() {
return "http://{$this->_host}:{
$this->_port}/selenium-server/driver/
";
public function buildUrlCmd($method, $arguments = array()) {
'cmd=' . urlencode($method),
foreach ($arguments as $param) {
$params[] = $i++ . '=' . urlencode(trim($param));
if (isset($this->_sessionId)) {
$params[] = 'sessionId=' . $this->_sessionId;
return $this->_server().
"?".
implode('&', $params);
public function cmd($method, $arguments = array()) {
$response =
$this->_sendRequest($url);
return (bool)@fsockopen($this->_host, $this->_port, $errno, $errstr, 30);
private function _initCurl($url) {
if (!function_exists('curl_init')) {
throw new Exception('this code currently requires the curl extension');
if (!$ch = curl_init($url)) {
throw new Exception('Unable to setup curl');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, floor($this->_timeout));
private function _sendRequest($url) {
$ch = $this->_initCurl($url);
$result =
curl_exec($ch);
if (($errno =
curl_errno($ch)) !=
0) {
throw new Exception('Curl returned non-null errno ' . $errno . ':' . curl_error($ch));
Documentation generated on Sun, 04 May 2008 09:22:00 -0500 by phpDocumentor 1.3.0