Skip to content

Commit 48e8db2

Browse files
committed
[grid] improved logging when driver discovery failed
1 parent f22e08f commit 48e8db2

File tree

7 files changed

+64
-2
lines changed

7 files changed

+64
-2
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
import com.google.auto.service.AutoService;
2323
import java.util.Optional;
24+
import java.util.logging.Level;
25+
import java.util.logging.Logger;
2426
import org.openqa.selenium.Capabilities;
2527
import org.openqa.selenium.ImmutableCapabilities;
2628
import org.openqa.selenium.SessionNotCreatedException;
@@ -29,10 +31,12 @@
2931
import org.openqa.selenium.WebDriverInfo;
3032
import org.openqa.selenium.chromium.ChromiumDriverInfo;
3133
import org.openqa.selenium.remote.CapabilityType;
34+
import org.openqa.selenium.remote.NoSuchDriverException;
3235
import org.openqa.selenium.remote.service.DriverFinder;
3336

3437
@AutoService(WebDriverInfo.class)
3538
public class ChromeDriverInfo extends ChromiumDriverInfo {
39+
private static final Logger LOG = Logger.getLogger(ChromeDriverInfo.class.getName());
3640

3741
@Override
3842
public String getDisplayName() {
@@ -64,7 +68,10 @@ public boolean isAvailable() {
6468
try {
6569
DriverFinder.getPath(ChromeDriverService.createDefaultService(), getCanonicalCapabilities());
6670
return true;
71+
} catch (NoSuchDriverException e) {
72+
return false;
6773
} catch (IllegalStateException | WebDriverException e) {
74+
LOG.log(Level.WARNING, "failed to discover driver path", e);
6875
return false;
6976
}
7077
}
@@ -75,7 +82,10 @@ public boolean isPresent() {
7582
DriverFinder.getPath(
7683
ChromeDriverService.createDefaultService(), getCanonicalCapabilities(), true);
7784
return true;
85+
} catch (NoSuchDriverException e) {
86+
return false;
7887
} catch (IllegalStateException | WebDriverException e) {
88+
LOG.log(Level.WARNING, "failed to discover driver path", e);
7989
return false;
8090
}
8191
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
import com.google.auto.service.AutoService;
2323
import java.util.Optional;
24+
import java.util.logging.Level;
25+
import java.util.logging.Logger;
2426
import org.openqa.selenium.Capabilities;
2527
import org.openqa.selenium.ImmutableCapabilities;
2628
import org.openqa.selenium.SessionNotCreatedException;
@@ -29,10 +31,12 @@
2931
import org.openqa.selenium.WebDriverInfo;
3032
import org.openqa.selenium.chromium.ChromiumDriverInfo;
3133
import org.openqa.selenium.remote.CapabilityType;
34+
import org.openqa.selenium.remote.NoSuchDriverException;
3235
import org.openqa.selenium.remote.service.DriverFinder;
3336

3437
@AutoService(WebDriverInfo.class)
3538
public class EdgeDriverInfo extends ChromiumDriverInfo {
39+
private static final Logger LOG = Logger.getLogger(EdgeDriverInfo.class.getName());
3640

3741
@Override
3842
public String getDisplayName() {
@@ -67,7 +71,10 @@ public boolean isAvailable() {
6771
try {
6872
DriverFinder.getPath(EdgeDriverService.createDefaultService(), getCanonicalCapabilities());
6973
return true;
74+
} catch (NoSuchDriverException e) {
75+
return false;
7076
} catch (IllegalStateException | WebDriverException e) {
77+
LOG.log(Level.WARNING, "failed to discover driver path", e);
7178
return false;
7279
}
7380
}
@@ -78,7 +85,10 @@ public boolean isPresent() {
7885
DriverFinder.getPath(
7986
EdgeDriverService.createDefaultService(), getCanonicalCapabilities(), true);
8087
return true;
88+
} catch (NoSuchDriverException e) {
89+
return false;
8190
} catch (IllegalStateException | WebDriverException e) {
91+
LOG.log(Level.WARNING, "failed to discover driver path", e);
8292
return false;
8393
}
8494
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@
2222

2323
import com.google.auto.service.AutoService;
2424
import java.util.Optional;
25+
import java.util.logging.Level;
26+
import java.util.logging.Logger;
2527
import org.openqa.selenium.Capabilities;
2628
import org.openqa.selenium.ImmutableCapabilities;
2729
import org.openqa.selenium.SessionNotCreatedException;
2830
import org.openqa.selenium.WebDriver;
2931
import org.openqa.selenium.WebDriverException;
3032
import org.openqa.selenium.WebDriverInfo;
33+
import org.openqa.selenium.remote.NoSuchDriverException;
3134
import org.openqa.selenium.remote.service.DriverFinder;
3235

3336
@AutoService(WebDriverInfo.class)
3437
public class GeckoDriverInfo implements WebDriverInfo {
38+
private static final Logger LOG = Logger.getLogger(GeckoDriverInfo.class.getName());
3539

3640
@Override
3741
public String getDisplayName() {
@@ -67,7 +71,10 @@ public boolean isAvailable() {
6771
try {
6872
DriverFinder.getPath(GeckoDriverService.createDefaultService(), getCanonicalCapabilities());
6973
return true;
74+
} catch (NoSuchDriverException e) {
75+
return false;
7076
} catch (IllegalStateException | WebDriverException e) {
77+
LOG.log(Level.WARNING, "failed to discover driver path", e);
7178
return false;
7279
}
7380
}
@@ -78,7 +85,10 @@ public boolean isPresent() {
7885
DriverFinder.getPath(
7986
GeckoDriverService.createDefaultService(), getCanonicalCapabilities(), true);
8087
return true;
88+
} catch (NoSuchDriverException e) {
89+
return false;
8190
} catch (IllegalStateException | WebDriverException e) {
91+
LOG.log(Level.WARNING, "failed to discover driver path", e);
8292
return false;
8393
}
8494
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,21 @@
2222

2323
import com.google.auto.service.AutoService;
2424
import java.util.Optional;
25+
import java.util.logging.Level;
26+
import java.util.logging.Logger;
2527
import org.openqa.selenium.Capabilities;
2628
import org.openqa.selenium.ImmutableCapabilities;
2729
import org.openqa.selenium.Platform;
2830
import org.openqa.selenium.SessionNotCreatedException;
2931
import org.openqa.selenium.WebDriver;
3032
import org.openqa.selenium.WebDriverException;
3133
import org.openqa.selenium.WebDriverInfo;
34+
import org.openqa.selenium.remote.NoSuchDriverException;
3235
import org.openqa.selenium.remote.service.DriverFinder;
3336

3437
@AutoService(WebDriverInfo.class)
3538
public class InternetExplorerDriverInfo implements WebDriverInfo {
39+
private static final Logger LOG = Logger.getLogger(InternetExplorerDriverInfo.class.getName());
3640

3741
@Override
3842
public String getDisplayName() {
@@ -68,7 +72,10 @@ public boolean isAvailable() {
6872
return true;
6973
}
7074
return false;
75+
} catch (NoSuchDriverException e) {
76+
return false;
7177
} catch (IllegalStateException | WebDriverException e) {
78+
LOG.log(Level.WARNING, "failed to discover driver path", e);
7279
return false;
7380
}
7481
}
@@ -82,7 +89,10 @@ public boolean isPresent() {
8289
return true;
8390
}
8491
return false;
92+
} catch (NoSuchDriverException e) {
93+
return false;
8594
} catch (IllegalStateException | WebDriverException e) {
95+
LOG.log(Level.WARNING, "failed to discover driver path", e);
8696
return false;
8797
}
8898
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.io.File;
2121
import org.openqa.selenium.Capabilities;
22+
import org.openqa.selenium.WebDriverException;
2223
import org.openqa.selenium.internal.Require;
2324
import org.openqa.selenium.manager.SeleniumManager;
2425
import org.openqa.selenium.manager.SeleniumManagerOutput.Result;
@@ -37,8 +38,8 @@ public static Result getPath(DriverService service, Capabilities options, boolea
3738
if (result.getDriverPath() == null) {
3839
try {
3940
result = SeleniumManager.getInstance().getDriverPath(options, offline);
40-
} catch (Exception e) {
41-
throw new NoSuchDriverException(
41+
} catch (RuntimeException e) {
42+
throw new WebDriverException(
4243
String.format("Unable to obtain: %s, error %s", options, e.getMessage()), e);
4344
}
4445
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,23 @@
2222

2323
import com.google.auto.service.AutoService;
2424
import java.util.Optional;
25+
import java.util.logging.Level;
26+
import java.util.logging.Logger;
2527
import org.openqa.selenium.Capabilities;
2628
import org.openqa.selenium.ImmutableCapabilities;
2729
import org.openqa.selenium.Platform;
2830
import org.openqa.selenium.SessionNotCreatedException;
2931
import org.openqa.selenium.WebDriver;
3032
import org.openqa.selenium.WebDriverException;
3133
import org.openqa.selenium.WebDriverInfo;
34+
import org.openqa.selenium.remote.NoSuchDriverException;
3235
import org.openqa.selenium.remote.service.DriverFinder;
3336

3437
@AutoService(WebDriverInfo.class)
3538
public class SafariDriverInfo implements WebDriverInfo {
3639

40+
private static final Logger LOG = Logger.getLogger(SafariDriverInfo.class.getName());
41+
3742
@Override
3843
public String getDisplayName() {
3944
return "Safari";
@@ -72,7 +77,10 @@ public boolean isAvailable() {
7277
return true;
7378
}
7479
return false;
80+
} catch (NoSuchDriverException e) {
81+
return false;
7582
} catch (IllegalStateException | WebDriverException e) {
83+
LOG.log(Level.WARNING, "failed to discover driver path", e);
7684
return false;
7785
}
7886
}
@@ -86,7 +94,10 @@ public boolean isPresent() {
8694
return true;
8795
}
8896
return false;
97+
} catch (NoSuchDriverException e) {
98+
return false;
8999
} catch (IllegalStateException | WebDriverException e) {
100+
LOG.log(Level.WARNING, "failed to discover driver path", e);
90101
return false;
91102
}
92103
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,22 @@
2222

2323
import com.google.auto.service.AutoService;
2424
import java.util.Optional;
25+
import java.util.logging.Level;
26+
import java.util.logging.Logger;
2527
import org.openqa.selenium.Capabilities;
2628
import org.openqa.selenium.ImmutableCapabilities;
2729
import org.openqa.selenium.Platform;
2830
import org.openqa.selenium.SessionNotCreatedException;
2931
import org.openqa.selenium.WebDriver;
3032
import org.openqa.selenium.WebDriverException;
3133
import org.openqa.selenium.WebDriverInfo;
34+
import org.openqa.selenium.remote.NoSuchDriverException;
3235
import org.openqa.selenium.remote.service.DriverFinder;
3336

3437
@SuppressWarnings("unused")
3538
@AutoService(WebDriverInfo.class)
3639
public class SafariTechPreviewDriverInfo implements WebDriverInfo {
40+
private static final Logger LOG = Logger.getLogger(SafariTechPreviewDriverInfo.class.getName());
3741

3842
@Override
3943
public String getDisplayName() {
@@ -73,7 +77,10 @@ public boolean isAvailable() {
7377
return true;
7478
}
7579
return false;
80+
} catch (NoSuchDriverException e) {
81+
return false;
7682
} catch (IllegalStateException | WebDriverException e) {
83+
LOG.log(Level.WARNING, "failed to discover driver path", e);
7784
return false;
7885
}
7986
}
@@ -89,7 +96,10 @@ public boolean isPresent() {
8996
return true;
9097
}
9198
return false;
99+
} catch (NoSuchDriverException e) {
100+
return false;
92101
} catch (IllegalStateException | WebDriverException e) {
102+
LOG.log(Level.WARNING, "failed to discover driver path", e);
93103
return false;
94104
}
95105
}

0 commit comments

Comments
 (0)