17
17
18
18
package org .openqa .selenium .testing .drivers ;
19
19
20
+ import org .openqa .selenium .Platform ;
20
21
import org .openqa .selenium .net .NetworkUtils ;
21
22
import org .openqa .selenium .net .PortProber ;
22
23
import org .openqa .selenium .net .UrlChecker ;
23
24
import org .openqa .selenium .os .CommandLine ;
24
25
26
+ import java .io .File ;
25
27
import java .net .MalformedURLException ;
26
28
import java .net .URL ;
27
29
import java .util .logging .Logger ;
@@ -61,8 +63,12 @@ public OutOfProcessSeleniumServer start(String mode, String... extraFlags) {
61
63
baseUrl = String .format ("http://%s:%d" , localAddress , port );
62
64
63
65
command = new CommandLine ("java" , Stream .concat (
64
- Stream .of ("-jar" , serverJar , mode , "--port" , String .valueOf (port )),
65
- Stream .of (extraFlags )).toArray (String []::new ));
66
+ Stream .of ("-jar" , serverJar , mode , "--port" , String .valueOf (port )),
67
+ Stream .of (extraFlags )).toArray (String []::new ));
68
+ if (Platform .getCurrent ().is (Platform .WINDOWS )) {
69
+ File workingDir = findBinRoot (new File ("." ).getAbsoluteFile ());
70
+ command .setWorkingDirectory (workingDir .getAbsolutePath ());
71
+ }
66
72
67
73
command .copyOutputTo (System .err );
68
74
log .info ("Starting selenium server: " + command .toString ());
@@ -88,6 +94,14 @@ public OutOfProcessSeleniumServer start(String mode, String... extraFlags) {
88
94
return this ;
89
95
}
90
96
97
+ private File findBinRoot (File dir ) {
98
+ if ("bin" .equals (dir .getName ())) {
99
+ return dir ;
100
+ } else {
101
+ return findBinRoot (dir .getParentFile ());
102
+ }
103
+ }
104
+
91
105
public void stop () {
92
106
if (command == null ) {
93
107
return ;
0 commit comments