Skip to content

Commit

Permalink
[java] Fixing remote tests on Windows, bazel does not make symlinks i…
Browse files Browse the repository at this point in the history
…nside runfiles directory so we should find server in another place
  • Loading branch information
barancev committed Nov 23, 2020
1 parent 4975741 commit 35e4776
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@

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;
Expand Down Expand Up @@ -61,8 +63,12 @@ public OutOfProcessSeleniumServer start(String mode, String... extraFlags) {
baseUrl = String.format("http://%s:%d", localAddress, port);

command = new CommandLine("java", Stream.concat(
Stream.of("-jar", serverJar, mode, "--port", String.valueOf(port)),
Stream.of(extraFlags)).toArray(String[]::new));
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());
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public WebDriver get() {
return driver;
}

private synchronized void startServer() {
private synchronized void startServer() {
if (started) {
return;
}
Expand Down

0 comments on commit 35e4776

Please sign in to comment.