Skip to content

Commit

Permalink
[grid] Avoid using SM offline when SM is true.
Browse files Browse the repository at this point in the history
Fixes #12521
  • Loading branch information
diemol committed Aug 28, 2023
1 parent ebaf121 commit 71ccb89
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions java/src/org/openqa/selenium/grid/node/config/NodeOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -573,22 +573,25 @@ private Map<WebDriverInfo, Collection<SessionFactory>> discoverDrivers(
}

// We don't expect duplicates, but they're fine
List<WebDriverInfo> infos =
StreamSupport.stream(ServiceLoader.load(WebDriverInfo.class).spliterator(), false)
.filter(WebDriverInfo::isPresent)
.sorted(Comparator.comparing(info -> info.getDisplayName().toLowerCase()))
.collect(Collectors.toList());

List<WebDriverInfo> infos = new ArrayList<>();
if (config.getBool(NODE_SECTION, "selenium-manager").orElse(DEFAULT_USE_SELENIUM_MANAGER)) {
List<String> present =
infos.stream().map(WebDriverInfo::getDisplayName).collect(Collectors.toList());
List<WebDriverInfo> driversSM =
StreamSupport.stream(ServiceLoader.load(WebDriverInfo.class).spliterator(), false)
.filter(info -> !present.contains(info.getDisplayName()))
.filter(WebDriverInfo::isAvailable)
.sorted(Comparator.comparing(info -> info.getDisplayName().toLowerCase()))
.collect(Collectors.toList());
infos.addAll(driversSM);
} else {
LOG.log(Level.INFO, "Looking for existing drivers on the PATH.");
LOG.log(
Level.INFO,
"Add '--selenium-manager true' to the startup command to setup drivers automatically.");
List<WebDriverInfo> localDrivers =
StreamSupport.stream(ServiceLoader.load(WebDriverInfo.class).spliterator(), false)
.filter(WebDriverInfo::isPresent)
.sorted(Comparator.comparing(info -> info.getDisplayName().toLowerCase()))
.collect(Collectors.toList());
infos.addAll(localDrivers);
}

// Same
Expand Down

0 comments on commit 71ccb89

Please sign in to comment.