Skip to content

Commit e891e66

Browse files
committed
Default to W3C; partial legacy WebDriver detection
1 parent 20c9c1b commit e891e66

File tree

6 files changed

+42
-42
lines changed

6 files changed

+42
-42
lines changed

lib/WebDriver/AbstractWebDriver.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ abstract class AbstractWebDriver
4444
/**
4545
* @var boolean
4646
*/
47-
protected $w3c;
47+
protected $legacy = false;
4848

4949
/**
5050
* Curl service
@@ -80,13 +80,13 @@ protected function obsoleteMethods()
8080
/**
8181
* Constructor
8282
*
83-
* @param string $url URL to Selenium server
84-
* @param boolean $w3c Is w3c driver?
83+
* @param string $url URL to Selenium server
84+
* @param boolean $legacy Is legacy driver?
8585
*/
86-
public function __construct($url = 'http://localhost:4444/wd/hub', $w3c = false)
86+
public function __construct($url = 'http://localhost:4444/wd/hub', $legacy = false)
8787
{
8888
$this->url = $url;
89-
$this->w3c = $w3c;
89+
$this->legacy = $legacy;
9090
$this->transientOptions = array();
9191
$this->curlService = ServiceFactory::getInstance()->getService('service.curl');
9292
}
@@ -150,13 +150,13 @@ public function getTransientOptions()
150150
}
151151

152152
/**
153-
* Is w3c driver?
153+
* Is legacy driver?
154154
*
155155
* @return boolean
156156
*/
157-
public function isW3c()
157+
public function isLegacy()
158158
{
159-
return $this->w3c;
159+
return $this->legacy;
160160
}
161161

162162
/**

lib/WebDriver/Container.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ abstract class Container extends AbstractWebDriver
4444
/**
4545
* {@inheritdoc}
4646
*/
47-
public function __construct($url, $w3c)
47+
public function __construct($url, $legacy)
4848
{
49-
parent::__construct($url, $w3c);
49+
parent::__construct($url, $legacy);
5050

5151
$locatorStrategy = new \ReflectionClass('WebDriver\LocatorStrategy');
5252
$this->strategies = $locatorStrategy->getConstants();
@@ -216,15 +216,15 @@ protected function webDriverElement($value)
216216
return new Element(
217217
$this->getElementPath($value[self::LEGACY_ELEMENT_ID]), // url
218218
$value[self::LEGACY_ELEMENT_ID], // id
219-
$this->w3c
219+
$this->legacy
220220
);
221221
}
222222

223223
if (array_key_exists(self::WEBDRIVER_ELEMENT_ID, (array) $value)) {
224224
return new Element(
225225
$this->getElementPath($value[self::WEBDRIVER_ELEMENT_ID]), // url
226226
$value[self::WEBDRIVER_ELEMENT_ID], // id
227-
$this->w3c
227+
$this->legacy
228228
);
229229
}
230230
}

lib/WebDriver/Element.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ protected function obsoleteMethods()
109109
/**
110110
* Constructor
111111
*
112-
* @param string $url URL
113-
* @param string $id element ID
114-
* @param boolean $w3c Is w3c?
112+
* @param string $url URL
113+
* @param string $id element ID
114+
* @param boolean $legacy Is legacy?
115115
*/
116-
public function __construct($url, $id, $w3c = false)
116+
public function __construct($url, $id, $legacy)
117117
{
118-
parent::__construct($url, $w3c);
118+
parent::__construct($url, $legacy);
119119

120120
$this->id = $id;
121121
}
@@ -141,7 +141,7 @@ public function getID()
141141
*/
142142
public function shadow()
143143
{
144-
return new Shadow($this->url . '/shadow', $this->w3c);
144+
return new Shadow($this->url . '/shadow', $this->legacy);
145145
}
146146

147147
/**

lib/WebDriver/LegacyWindow.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ public function getHandle()
8181
*
8282
* @param string $url URL
8383
* @param string $windowHandle Window handle
84-
* @param boolean $w3c Is W3C?
84+
* @param boolean $legacy Is legacy?
8585
*/
86-
public function __construct($url, $windowHandle, $w3c = false)
86+
public function __construct($url, $windowHandle, $legacy = true)
8787
{
8888
$this->windowHandle = $windowHandle;
8989

90-
parent::__construct($url . '/' . $windowHandle, $w3c);
90+
parent::__construct($url . '/' . $windowHandle, $legacy);
9191
}
9292
}

lib/WebDriver/Session.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ public function deleteCookie($cookieName)
236236
public function window()
237237
{
238238
// legacy window methods
239-
if (! $this->w3c) {
239+
if ($this->legacy) {
240240
return call_user_func_array(array($this, 'legacyWindow'), func_get_args());
241241
}
242242

243-
return new Window($this->url . '/window', $this->w3c);
243+
return new Window($this->url . '/window', $this->legacy);
244244
}
245245

246246
/**
@@ -270,7 +270,7 @@ public function legacyWindow()
270270
}
271271

272272
// chaining
273-
return new LegacyWindow($this->url . '/window', $arg, $this->w3c);
273+
return new LegacyWindow($this->url . '/window', $arg, $this->legacy);
274274
}
275275

276276
/**
@@ -317,7 +317,7 @@ public function frame()
317317
}
318318

319319
// chaining
320-
return new Frame($this->url . '/frame', $this->w3c);
320+
return new Frame($this->url . '/frame', $this->legacy);
321321
}
322322

323323
/**
@@ -339,13 +339,13 @@ public function timeouts()
339339
}
340340

341341
if (func_num_args() === 2) {
342-
$arg = $this->w3c
342+
$arg = $this->legacy
343343
? array(
344-
func_get_arg(0) => func_get_arg(1), // 'script' or 'implicit' => timeout in milliseconds
345-
)
346-
: array(
347344
'type' => func_get_arg(0), // 'script' or 'implicit'
348345
'ms' => func_get_arg(1), // timeout in milliseconds
346+
)
347+
: array(
348+
func_get_arg(0) => func_get_arg(1), // 'script' or 'implicit' => timeout in milliseconds
349349
);
350350

351351
$this->curl('POST', '/timeouts', $arg);
@@ -354,7 +354,7 @@ public function timeouts()
354354
}
355355

356356
// chaining
357-
return new Timeouts($this->url . '/timeouts', $this->w3c);
357+
return new Timeouts($this->url . '/timeouts', $this->legacy);
358358
}
359359

360360
/**
@@ -365,7 +365,7 @@ public function timeouts()
365365
*/
366366
public function ime()
367367
{
368-
return new Ime($this->url . '/ime', $this->w3c);
368+
return new Ime($this->url . '/ime', $this->legacy);
369369
}
370370

371371
/**
@@ -390,7 +390,7 @@ public function activeElement()
390390
*/
391391
public function touch()
392392
{
393-
return new Touch($this->url . '/touch', $this->w3c);
393+
return new Touch($this->url . '/touch', $this->legacy);
394394
}
395395

396396
/**
@@ -401,7 +401,7 @@ public function touch()
401401
*/
402402
public function localStorage()
403403
{
404-
return new Storage\Local($this->url . '/local_storage', $this->w3c);
404+
return new Storage\Local($this->url . '/local_storage', $this->legacy);
405405
}
406406

407407
/**
@@ -412,7 +412,7 @@ public function localStorage()
412412
*/
413413
public function sessionStorage()
414414
{
415-
return new Storage\Session($this->url . '/session_storage', $this->w3c);
415+
return new Storage\Session($this->url . '/session_storage', $this->legacy);
416416
}
417417

418418
/**
@@ -423,7 +423,7 @@ public function sessionStorage()
423423
*/
424424
public function applicationCache()
425425
{
426-
return new ApplicationCache($this->url . '/application_cache', $this->w3c);
426+
return new ApplicationCache($this->url . '/application_cache', $this->legacy);
427427
}
428428

429429
/**
@@ -451,7 +451,7 @@ public function log()
451451
}
452452

453453
// chaining
454-
return new Log($this->url . '/log', $this->w3c);
454+
return new Log($this->url . '/log', $this->legacy);
455455
}
456456

457457
/**
@@ -462,7 +462,7 @@ public function log()
462462
*/
463463
public function alert()
464464
{
465-
return new Alert($this->url . '/alert', $this->w3c);
465+
return new Alert($this->url . '/alert', $this->legacy);
466466
}
467467

468468
/**
@@ -481,7 +481,7 @@ public function execute()
481481
return $result['value'];
482482
}
483483

484-
return new Execute($this->url . '/execute', $this->w3c);
484+
return new Execute($this->url . '/execute', $this->legacy);
485485
}
486486

487487
/**

lib/WebDriver/WebDriver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public function session($requiredCapabilities = Browser::FIREFOX, $desiredCapabi
7272
);
7373

7474
$capabilities = isset($result['value']['capabilities']) ? $result['value']['capabilities'] : null;
75-
$this->w3c = !! $capabilities;
75+
$this->legacy = ! $capabilities;
7676

77-
$session = new Session($result['sessionUrl'], $this->w3c);
77+
$session = new Session($result['sessionUrl'], $this->legacy);
7878
$session->setCapabilities($capabilities);
7979

8080
return $session;
@@ -88,9 +88,9 @@ public function sessions()
8888
$result = $this->curl('GET', '/sessions');
8989
$sessions = array();
9090

91-
// @todo initialize $this->w3c if sessions() is called before session()
91+
// @todo initialize $this->legacy if sessions() is called before session()
9292
foreach ($result['value'] as $session) {
93-
$sessions[] = new Session($this->url . '/session/' . $session['id'], $this->w3c);
93+
$sessions[] = new Session($this->url . '/session/' . $session['id'], $this->legacy);
9494
}
9595

9696
return $sessions;

0 commit comments

Comments
 (0)