@@ -145,13 +145,26 @@ class PHPUnit_Extensions_SeleniumTestCase_Driver
145
145
*/
146
146
protected $ verificationErrors = array ();
147
147
148
+ /**
149
+ * @var array
150
+ */
151
+ private $ webDriverCapabilities ;
152
+
148
153
public function __construct ()
149
154
{
150
155
if (empty (self ::$ autoGeneratedCommands )) {
151
156
self ::autoGenerateCommands ();
152
157
}
153
158
}
154
159
160
+ /**
161
+ * Only browserName is supported.
162
+ */
163
+ public function setWebDriverCapabilities (array $ capabilities )
164
+ {
165
+ $ this ->webDriverCapabilities = $ capabilities ;
166
+ }
167
+
155
168
/**
156
169
* @return string
157
170
*/
@@ -163,6 +176,21 @@ public function start()
163
176
);
164
177
}
165
178
179
+ if ($ this ->webDriverCapabilities !== NULL ) {
180
+
181
+ $ seleniumServerUrl = PHPUnit_Extensions_Selenium2TestCase_URL::fromHostAndPort ($ this ->host , $ this ->port );
182
+ $ driver = new PHPUnit_Extensions_Selenium2TestCase_Driver ($ seleniumServerUrl );
183
+ $ session = $ driver ->startSession ($ this ->webDriverCapabilities ['browserName ' ], new PHPUnit_Extensions_Selenium2TestCase_URL ($ this ->browserUrl ));
184
+ $ webDriverSessionId = $ session ->id ();
185
+ $ this ->sessionId = $ this ->getString (
186
+ 'getNewBrowserSession ' ,
187
+ array ($ this ->browser , $ this ->browserUrl , '' ,
188
+ "webdriver.remote.sessionid= $ webDriverSessionId " )
189
+ );
190
+
191
+ $ this ->doCommand ('setTimeout ' , array ($ this ->seleniumTimeout * 1000 ));
192
+ }
193
+
166
194
if (!isset ($ this ->sessionId )) {
167
195
$ this ->sessionId = $ this ->getString (
168
196
'getNewBrowserSession ' ,
@@ -918,10 +946,11 @@ public function __call($command, $arguments)
918
946
*
919
947
* @param string $command
920
948
* @param array $arguments
949
+ * @param array $namedArguments
921
950
* @return string
922
951
* @author Seth Casana <[email protected] >
923
952
*/
924
- protected function doCommand ($ command , array $ arguments = array ())
953
+ protected function doCommand ($ command , array $ arguments = array (), array $ namedArguments = array () )
925
954
{
926
955
$ url = sprintf (
927
956
'http://%s:%s/selenium-server/driver/ ' ,
@@ -940,6 +969,9 @@ protected function doCommand($command, array $arguments = array())
940
969
$ postData .= sprintf ('&%s=%s ' , $ argNum , urlencode (trim ($ arguments [$ i ])));
941
970
}
942
971
}
972
+ foreach ($ namedArguments as $ key => $ value ) {
973
+ $ postData .= sprintf ('&%s=%s ' , $ key , urlencode ($ value ));
974
+ }
943
975
944
976
if (isset ($ this ->sessionId )) {
945
977
$ postData .= sprintf ('&%s=%s ' , 'sessionId ' , $ this ->sessionId );
0 commit comments