From 71ccb89cf39c2c3571f8de2e369ea2698646a677 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 28 Aug 2023 12:03:11 +0200 Subject: [PATCH] [grid] Avoid using SM offline when SM is true. Fixes #12521 --- .../grid/node/config/NodeOptions.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/java/src/org/openqa/selenium/grid/node/config/NodeOptions.java b/java/src/org/openqa/selenium/grid/node/config/NodeOptions.java index 57113982f66eb..a174b22d22bc2 100644 --- a/java/src/org/openqa/selenium/grid/node/config/NodeOptions.java +++ b/java/src/org/openqa/selenium/grid/node/config/NodeOptions.java @@ -573,22 +573,25 @@ private Map> discoverDrivers( } // We don't expect duplicates, but they're fine - List infos = - StreamSupport.stream(ServiceLoader.load(WebDriverInfo.class).spliterator(), false) - .filter(WebDriverInfo::isPresent) - .sorted(Comparator.comparing(info -> info.getDisplayName().toLowerCase())) - .collect(Collectors.toList()); - + List infos = new ArrayList<>(); if (config.getBool(NODE_SECTION, "selenium-manager").orElse(DEFAULT_USE_SELENIUM_MANAGER)) { - List present = - infos.stream().map(WebDriverInfo::getDisplayName).collect(Collectors.toList()); List 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 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