[java] Fixing remote tests on Windows, bazel does not make symlinks inside runfiles directory so we should find server in another place
package org.openqa.selenium.testing.drivers;
+import org.openqa.selenium.Platform;
import org.openqa.selenium.net.NetworkUtils;
import org.openqa.selenium.net.PortProber;
import org.openqa.selenium.net.UrlChecker;
import org.openqa.selenium.os.CommandLine;
+import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Logger;
@@ -63,6 +65,10 @@ public OutOfProcessSeleniumServer start(String mode, String... extraFlags) {
command = new CommandLine("java", Stream.concat(
Stream.of("-jar", serverJar, mode, "--port", String.valueOf(port)),
Stream.of(extraFlags)).toArray(String[]::new));
+ if (Platform.getCurrent().is(Platform.WINDOWS)) {
+ File workingDir = findBinRoot(new File(".").getAbsoluteFile());
+ command.setWorkingDirectory(workingDir.getAbsolutePath());
+ }
command.copyOutputTo(System.err);
log.info("Starting selenium server: " + command.toString());
@@ -88,6 +94,14 @@ public OutOfProcessSeleniumServer start(String mode, String... extraFlags) {
return this;
}
+ private File findBinRoot(File dir) {
+ if ("bin".equals(dir.getName())) {
+ return dir;
+ } else {
+ return findBinRoot(dir.getParentFile());
+ }
+ }
+
public void stop() {
if (command == null) {
return;
