@@ -60,7 +60,7 @@ class Session extends Container
6060 /**
6161 * @var boolean
6262 */
63- private $ legacy = null ;
63+ private $ w3c = null ;
6464
6565 /**
6666 * {@inheritdoc}
@@ -114,6 +114,30 @@ protected function obsoleteMethods()
114114 );
115115 }
116116
117+ /**
118+ * Constructor
119+ *
120+ * @param string $url URL to Selenium server
121+ * @param array|null $capabilities
122+ */
123+ public function __construct ($ url , $ capabilities )
124+ {
125+ parent ::__construct ($ url );
126+
127+ $ this ->capabilities = $ capabilities ;
128+ $ this ->w3c = !! $ capabilities ;
129+ }
130+
131+ /**
132+ * Is W3C webdriver?
133+ *
134+ * @return boolean
135+ */
136+ public function isW3C ()
137+ {
138+ return $ this ->w3c ;
139+ }
140+
117141 /**
118142 * Open URL: /session/:sessionId/url (POST)
119143 * An alternative to $session->url($url);
@@ -228,7 +252,7 @@ public function deleteCookie($cookieName)
228252 */
229253 public function getWindowHandle ()
230254 {
231- $ result = $ this ->curl ('GET ' , $ this ->legacy ? '/window_handle ' : '/window ' );
255+ $ result = $ this ->curl ('GET ' , $ this ->w3c ? '/window ' : '/window_handle ' );
232256
233257 return $ result ['value ' ];
234258 }
@@ -274,7 +298,7 @@ public function window()
274298 }
275299
276300 // chaining (with optional handle in $arg)
277- return $ this ->legacy ? new LegacyWindow ($ this ->url . '/window ' , $ arg ) : new Window ($ this ->url . '/window ' , $ arg );
301+ return $ this ->w3c ? new Window ($ this ->url . '/window ' , $ arg ) : new LegacyWindow ($ this ->url . '/window ' , $ arg );
278302 }
279303
280304 /**
@@ -359,7 +383,7 @@ public function timeouts()
359383 $ type = func_get_arg (0 ); // 'script', 'implicit', or 'pageLoad' (legacy: 'pageLoad')
360384 $ timeout = func_get_arg (1 ); // timeout in milliseconds
361385
362- $ arg = $ this ->legacy ? array (' type ' => $ type, ' ms ' => $ timeout ) : array ($ type => $ timeout );
386+ $ arg = $ this ->w3c ? array ($ type => $ timeout ) : array (' type ' => $ type, ' ms ' => $ timeout );
363387
364388 $ this ->curl ('POST ' , '/timeouts ' , $ arg );
365389
@@ -489,7 +513,7 @@ public function execute()
489513 {
490514 // execute script
491515 if (func_num_args () > 0 ) {
492- $ execute = $ this ->legacy ? new LegacyExecute ($ this ->url ) : new Execute ($ this ->url . ' /execute ' );
516+ $ execute = $ this ->w3c ? new Execute ($ this ->url . ' /execute ' ) : new LegacyExecute ($ this ->url );
493517 $ result = $ execute ->sync (func_get_arg (0 ));
494518
495519 return $ result ;
@@ -507,32 +531,12 @@ public function execute()
507531 */
508532 public function execute_async ()
509533 {
510- $ execute = $ this ->legacy ? new LegacyExecute ($ this ->url ) : new Execute ($ this ->url . ' /execute ' );
534+ $ execute = $ this ->w3c ? new Execute ($ this ->url . ' /execute ' ) : new LegacyExecute ($ this ->url );
511535 $ result = $ execute ->async (func_get_arg (0 ));
512536
513537 return $ result ;
514538 }
515539
516- /**
517- * Set capabilities
518- *
519- * @param array $capabilities
520- */
521- public function setCapabilities ($ capabilities )
522- {
523- $ this ->capabilities = $ capabilities ;
524- }
525-
526- /**
527- * Set legacy
528- *
529- * @param boolean $legacy
530- */
531- public function setLegacy ($ legacy )
532- {
533- $ this ->legacy = $ legacy ;
534- }
535-
536540 /**
537541 * {@inheritdoc}
538542 */
0 commit comments