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; }