Skip to content

Commit 673cd7e

Browse files
committed
[grid] need to use DriverFinder to check if drivers are available
1 parent 2771310 commit 673cd7e

8 files changed

Lines changed: 32 additions & 8 deletions

File tree

java/src/org/openqa/selenium/chrome/ChromeDriverInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.openqa.selenium.WebDriverInfo;
2828
import org.openqa.selenium.chromium.ChromiumDriverInfo;
2929
import org.openqa.selenium.remote.CapabilityType;
30+
import org.openqa.selenium.remote.service.DriverFinder;
3031

3132
import java.util.Optional;
3233

@@ -64,7 +65,7 @@ public boolean isSupportingBiDi() {
6465
@Override
6566
public boolean isAvailable() {
6667
try {
67-
ChromeDriverService.createDefaultService();
68+
DriverFinder.getPath(ChromeDriverService.createDefaultService());
6869
return true;
6970
} catch (IllegalStateException | WebDriverException e) {
7071
return false;

java/src/org/openqa/selenium/edge/EdgeDriverInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.openqa.selenium.WebDriverException;
2626
import org.openqa.selenium.WebDriverInfo;
2727
import org.openqa.selenium.chromium.ChromiumDriverInfo;
28+
import org.openqa.selenium.remote.service.DriverFinder;
2829

2930
import java.util.Optional;
3031

@@ -65,7 +66,7 @@ public boolean isSupportingBiDi() {
6566
@Override
6667
public boolean isAvailable() {
6768
try {
68-
EdgeDriverService.createDefaultService();
69+
DriverFinder.getPath(EdgeDriverService.createDefaultService());
6970
return true;
7071
} catch (IllegalStateException | WebDriverException e) {
7172
return false;

java/src/org/openqa/selenium/firefox/GeckoDriverInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.openqa.selenium.WebDriver;
2929
import org.openqa.selenium.WebDriverException;
3030
import org.openqa.selenium.WebDriverInfo;
31+
import org.openqa.selenium.remote.service.DriverFinder;
3132

3233
import java.util.Optional;
3334

@@ -69,7 +70,7 @@ public boolean isSupportingBiDi() {
6970
@Override
7071
public boolean isAvailable() {
7172
try {
72-
GeckoDriverService.createDefaultService();
73+
DriverFinder.getPath(GeckoDriverService.createDefaultService());
7374
return true;
7475
} catch (IllegalStateException | WebDriverException e) {
7576
return false;

java/src/org/openqa/selenium/ie/InternetExplorerDriverInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.openqa.selenium.WebDriver;
2727
import org.openqa.selenium.WebDriverException;
2828
import org.openqa.selenium.WebDriverInfo;
29+
import org.openqa.selenium.remote.service.DriverFinder;
2930

3031
import java.util.Optional;
3132

@@ -65,7 +66,7 @@ public boolean isSupportingBiDi() {
6566
public boolean isAvailable() {
6667
try {
6768
if (Platform.getCurrent().is(Platform.WINDOWS)) {
68-
InternetExplorerDriverService.createDefaultService();
69+
DriverFinder.getPath(InternetExplorerDriverService.createDefaultService());
6970
return true;
7071
}
7172
return false;

java/src/org/openqa/selenium/manager/SeleniumManager.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717
package org.openqa.selenium.manager;
1818

19+
import com.google.common.collect.ImmutableList;
1920
import com.google.common.io.CharStreams;
2021
import org.openqa.selenium.Beta;
2122
import org.openqa.selenium.Capabilities;
@@ -165,4 +166,13 @@ public String getDriverPath(Capabilities options) {
165166
}
166167
return runCommand(commandList.toArray(new String[0]));
167168
}
169+
170+
public String getDriverPath(String driverName) {
171+
File binaryFile = getBinary();
172+
if(binaryFile == null) {
173+
return null;
174+
}
175+
ImmutableList<String> commandList = ImmutableList.of(binaryFile.getAbsolutePath(), "--driver", driverName);
176+
return runCommand(commandList.toArray(new String[0]));
177+
}
168178
}

java/src/org/openqa/selenium/remote/service/DriverFinder.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
public class DriverFinder {
1212
private static final Logger LOG = Logger.getLogger(DriverFinder.class.getName());
1313

14-
public static String getPath(DriverServiceInfo serviceInfo, Capabilities options) {
14+
public static String getPath(DriverServiceInfo serviceInfo) {
15+
return getPath(serviceInfo, null);
16+
}
17+
18+
public static String getPath(DriverServiceInfo serviceInfo, Capabilities options) {
1519
String exePath = serviceInfo.getDriverProperty();
1620

1721
if (exePath == null && serviceInfo.getDriverExecutable() != null) {
@@ -22,7 +26,11 @@ public static String getPath(DriverServiceInfo serviceInfo, Capabilities options
2226

2327
if (exePath == null) {
2428
try {
25-
exePath = SeleniumManager.getInstance().getDriverPath(options);
29+
if (options == null) {
30+
exePath = SeleniumManager.getInstance().getDriverPath(serviceInfo.getDriverName());
31+
} else {
32+
exePath = SeleniumManager.getInstance().getDriverPath(options);
33+
}
2634
} catch (Exception e) {
2735
LOG.warning(String.format("Unable to obtain %s using Selenium Manager: %s", serviceInfo.getDriverName(), e.getMessage()));
2836
}

java/src/org/openqa/selenium/safari/SafariDriverInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.openqa.selenium.WebDriver;
2626
import org.openqa.selenium.WebDriverException;
2727
import org.openqa.selenium.WebDriverInfo;
28+
import org.openqa.selenium.remote.service.DriverFinder;
2829

2930
import java.util.Optional;
3031

@@ -69,7 +70,7 @@ public boolean isSupportingBiDi() {
6970
@Override
7071
public boolean isAvailable() {
7172
try {
72-
SafariDriverService.createDefaultService();
73+
DriverFinder.getPath(SafariDriverService.createDefaultService());
7374
return true;
7475
} catch (IllegalStateException | WebDriverException e) {
7576
return false;

java/src/org/openqa/selenium/safari/SafariTechPreviewDriverInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.openqa.selenium.WebDriver;
2626
import org.openqa.selenium.WebDriverException;
2727
import org.openqa.selenium.WebDriverInfo;
28+
import org.openqa.selenium.remote.service.DriverFinder;
2829

2930
import java.util.Optional;
3031

@@ -70,7 +71,7 @@ public boolean isSupportingBiDi() {
7071
@Override
7172
public boolean isAvailable() {
7273
try {
73-
SafariTechPreviewDriverService.createDefaultService();
74+
DriverFinder.getPath(SafariTechPreviewDriverService.createDefaultService());
7475
return true;
7576
} catch (IllegalStateException | WebDriverException e) {
7677
return false;

0 commit comments

Comments
 (0)