From 19da22a5886836078159532482b2f27b3998b33a Mon Sep 17 00:00:00 2001 From: Boni Garcia Date: Thu, 25 Jul 2024 16:38:03 +0200 Subject: [PATCH] Fix logic to detect browser version --- .../wdm/versions/VersionDetector.java | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/main/java/io/github/bonigarcia/wdm/versions/VersionDetector.java b/src/main/java/io/github/bonigarcia/wdm/versions/VersionDetector.java index d90c0805c..695578ac8 100644 --- a/src/main/java/io/github/bonigarcia/wdm/versions/VersionDetector.java +++ b/src/main/java/io/github/bonigarcia/wdm/versions/VersionDetector.java @@ -231,38 +231,38 @@ public Optional getBrowserPath(String browserName) { public Optional getBrowserVersionFromTheShell(String browserName) { Optional browserVersionUsingProperties = empty(); -// String browserVersionDetectionCommand = config -// .getBrowserVersionDetectionCommand(); -// if (!isNullOrEmpty(browserVersionDetectionCommand)) { -// browserVersionUsingProperties = getBrowserVersionUsingCommand( -// browserVersionDetectionCommand); -// } -// if (browserVersionUsingProperties.isPresent()) { -// return browserVersionUsingProperties; -// } -// -// boolean online = config.isCommandsPropertiesOnlineFirst(); -// String propertiesName = COMMANDS_PROPERTIES; -// Properties commandsProperties = getProperties(propertiesName, online); -// -// String onlineMessage = online ? ONLINE : LOCAL; -// log.debug("Detecting {} version using {} {}", browserName, -// onlineMessage, propertiesName); -// -// browserVersionUsingProperties = getBrowserVersionUsingProperties( -// browserName, commandsProperties); -// -// if (!browserVersionUsingProperties.isPresent()) { -// String notOnlineMessage = online ? LOCAL : ONLINE; -// log.debug( -// "Browser version for {} not detected using {} properties (using {} {})", -// browserName, onlineMessage, notOnlineMessage, -// propertiesName); -// -// commandsProperties = getProperties(propertiesName, !online); -// browserVersionUsingProperties = getBrowserVersionUsingProperties( -// browserName, commandsProperties); -// } + String browserVersionDetectionCommand = config + .getBrowserVersionDetectionCommand(); + if (!isNullOrEmpty(browserVersionDetectionCommand)) { + browserVersionUsingProperties = getBrowserVersionUsingCommand( + browserVersionDetectionCommand); + } + if (browserVersionUsingProperties.isPresent()) { + return browserVersionUsingProperties; + } + + boolean online = config.isCommandsPropertiesOnlineFirst(); + String propertiesName = COMMANDS_PROPERTIES; + Properties commandsProperties = getProperties(propertiesName, online); + + String onlineMessage = online ? ONLINE : LOCAL; + log.debug("Detecting {} version using {} {}", browserName, + onlineMessage, propertiesName); + + browserVersionUsingProperties = getBrowserVersionUsingProperties( + browserName, commandsProperties); + + if (!browserVersionUsingProperties.isPresent()) { + String notOnlineMessage = online ? LOCAL : ONLINE; + log.debug( + "Browser version for {} not detected using {} properties (using {} {})", + browserName, onlineMessage, notOnlineMessage, + propertiesName); + + commandsProperties = getProperties(propertiesName, !online); + browserVersionUsingProperties = getBrowserVersionUsingProperties( + browserName, commandsProperties); + } return browserVersionUsingProperties; }