Skip to content

Commit d7772ff

Browse files
committed
Improving Firefox executable discovery on Linux
1 parent 0209848 commit d7772ff

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

java/client/src/org/openqa/selenium/firefox/FirefoxBinary.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
import java.io.File;
4040
import java.io.IOException;
4141
import java.io.OutputStream;
42+
import java.nio.file.Files;
43+
import java.nio.file.Path;
4244
import java.util.Collections;
4345
import java.util.HashSet;
4446
import java.util.List;
@@ -439,7 +441,26 @@ private static Stream<Executable> locateFirefoxBinariesFromPlatform() {
439441

440442
String systemFirefox = CommandLine.find("firefox");
441443
if (systemFirefox != null) {
442-
executables.add(new Executable(new File(systemFirefox)));
444+
Path firefoxPath = new File(systemFirefox).toPath();
445+
if (Files.isSymbolicLink(firefoxPath)) {
446+
try {
447+
Path realPath = Files.readSymbolicLink(firefoxPath);
448+
File attempt1 = realPath.getParent().resolve("firefox").toFile();
449+
if (attempt1.exists()) {
450+
executables.add(new Executable(attempt1));
451+
} else {
452+
File attempt2 = realPath.getParent().resolve("firefox-bin").toFile();
453+
if (attempt2.exists()) {
454+
executables.add(new Executable(attempt2));
455+
}
456+
}
457+
} catch (IOException e) {
458+
// ignore this path
459+
}
460+
461+
} else {
462+
executables.add(new Executable(new File(systemFirefox)));
463+
}
443464
}
444465

445466
return executables.build().stream();

0 commit comments

Comments
 (0)