Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #12 from sbtqa/new-chrome-scheme
Browse files Browse the repository at this point in the history
Now LATEST is the Stable chrome version
  • Loading branch information
clicman authored Aug 28, 2023
2 parents c6de796 + 643196f commit 55d066b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/main/java/io/github/bonigarcia/wdm/ChromeDriverManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.slf4j.Logger;

import java.io.IOException;
Expand All @@ -29,6 +30,7 @@
import java.util.stream.Collectors;

import static io.github.bonigarcia.wdm.WdmConfig.getString;
import static io.github.bonigarcia.wdm.WdmConfig.getUrl;
import static java.lang.invoke.MethodHandles.lookup;
import static java.util.Arrays.asList;
import static org.slf4j.LoggerFactory.getLogger;
Expand Down Expand Up @@ -113,6 +115,31 @@ protected String getCurrentVersion(URL url, String driverName) {
}
}

@Override
protected List<URL> getLatest(List<URL> list, List<String> match) {
log.trace("Checking the latest stable version of {} with URL list {}", match,
list);
URL chromeChannels = getUrl("wdm.chromedriverUrl.channels");
Function<JsonElement, List<URL>> stableParser = jsonElement -> {
JsonObject channels = jsonElement.getAsJsonObject().getAsJsonObject("channels");
String stableVersion = channels.getAsJsonObject("Stable").getAsJsonPrimitive("version").getAsString();

return list.stream().filter(url -> url.toString().contains(stableVersion)).collect(Collectors.toList());
};

List<URL> out = new ArrayList<>();
try {
out.addAll(getDriversFromJson(chromeChannels, stableParser));
} catch (IOException e) {
log.error("Cannot determine latest version for {}", match);
return out;
}
versionToDownload = getCurrentVersion(out.get(0), "chromedriver");

log.info("Latest version of {} is {}", match, versionToDownload);
return out;
}

@Override
public BrowserManager useTaobaoMirror() {
return useTaobaoMirror("wdm.chromeDriverTaobaoUrl");
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/webdrivermanager.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ wdm.useBetaVersions=false
wdm.timeout=30

wdm.chromeDriverUrl.legacy=https://chromedriver.storage.googleapis.com/
wdm.chromedriverUrl.channels=https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json
wdm.chromeDriverUrl=https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
wdm.chromeDriverTaobaoUrl=http://npm.taobao.org/mirrors/chromedriver/
wdm.chromeDriverExport=webdriver.chrome.driver
Expand Down

0 comments on commit 55d066b

Please sign in to comment.