diff --git a/src/main/java/org/cloud/sonic/agent/bridge/android/AndroidDeviceBridgeTool.java b/src/main/java/org/cloud/sonic/agent/bridge/android/AndroidDeviceBridgeTool.java index 4d2fdd92..286ed4ce 100755 --- a/src/main/java/org/cloud/sonic/agent/bridge/android/AndroidDeviceBridgeTool.java +++ b/src/main/java/org/cloud/sonic/agent/bridge/android/AndroidDeviceBridgeTool.java @@ -891,6 +891,7 @@ public static File getChromeDriver(IDevice iDevice, String fullChromeVersion) th } String majorChromeVersion = getMajorChromeVersion(fullChromeVersion); + boolean greaterThen114 = majorChromeVersion != null && Integer.parseInt(majorChromeVersion) > 114; HttpHeaders headers = new HttpHeaders(); if (system.contains("win")) { system = "win32"; @@ -899,29 +900,48 @@ public static File getChromeDriver(IDevice iDevice, String fullChromeVersion) th } else { String arch = System.getProperty("os.arch").toLowerCase(); if (arch.contains("aarch64")) { - String driverList = restTemplate.exchange(String.format("https://registry.npmmirror.com/-/binary/chromedriver/%s/", - ChromeDriverMap.getMap().get(majorChromeVersion)), HttpMethod.GET, new HttpEntity(headers), String.class).getBody(); - boolean findM1ChromeDriver = false; - for (Object obj : JSONArray.parseArray(driverList)) { - JSONObject jsonObject = JSONObject.parseObject(obj.toString()); - String fullName = jsonObject.getString("name"); - if (fullName.contains("m1") || fullName.contains("arm")) { - system = fullName.substring(fullName.indexOf("mac"), fullName.indexOf(".")); - findM1ChromeDriver = true; - break; + if (greaterThen114) { + system = "mac-arm64"; + } else { + String driverList = restTemplate.exchange(String.format("https://registry.npmmirror.com/-/binary/chromedriver/%s/", + ChromeDriverMap.getMap().get(majorChromeVersion)), HttpMethod.GET, new HttpEntity(headers), String.class).getBody(); + boolean findM1ChromeDriver = false; + for (Object obj : JSONArray.parseArray(driverList)) { + JSONObject jsonObject = JSONObject.parseObject(obj.toString()); + String fullName = jsonObject.getString("name"); + if (fullName.contains("m1") || fullName.contains("arm")) { + system = fullName.substring(fullName.indexOf("mac"), fullName.indexOf(".")); + findM1ChromeDriver = true; + break; + } + } + // <=86版本,google未提供M1架构的chromeDriver,改为固定用chromedriver_mac64.zip + if (!findM1ChromeDriver) { + system = "mac64"; } } - // <=86版本,google未提供M1架构的chromeDriver,改为固定用chromedriver_mac64.zip - if (!findM1ChromeDriver) { + } else { + if (greaterThen114) { + system = "mac-x64"; + } else { system = "mac64"; } - } else { - system = "mac64"; } } - File file = DownloadTool.download(String.format("https://cdn.npmmirror.com/binaries/chromedriver/%s/chromedriver_%s.zip", - ChromeDriverMap.getMap().get(majorChromeVersion), system)); - return FileTool.unZipChromeDriver(file, fullChromeVersion); + File file; + if (greaterThen114) { + // Starting with M115 the ChromeDriver release process is integrated with that of Chrome. + // The latest Chrome + ChromeDriver releases per release channel (Stable, Beta, Dev, Canary) are available + // at the Chrome for Testing (CfT) availability dashboard. + file = DownloadTool.download(String.format( + "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/%s/%s/chromedriver-%s.zip", + ChromeDriverMap.getMap().get(majorChromeVersion), system, system)); + } else { + file = DownloadTool.download(String.format( + "https://cdn.npmmirror.com/binaries/chromedriver/%s/chromedriver_%s.zip", + ChromeDriverMap.getMap().get(majorChromeVersion), system)); + } + return FileTool.unZipChromeDriver(file, fullChromeVersion, greaterThen114, system); } public static List getWebView(IDevice iDevice) { diff --git a/src/main/java/org/cloud/sonic/agent/common/maps/ChromeDriverMap.java b/src/main/java/org/cloud/sonic/agent/common/maps/ChromeDriverMap.java index 0c7504c8..7469b0a3 100755 --- a/src/main/java/org/cloud/sonic/agent/common/maps/ChromeDriverMap.java +++ b/src/main/java/org/cloud/sonic/agent/common/maps/ChromeDriverMap.java @@ -86,6 +86,12 @@ public class ChromeDriverMap { put("112", "112.0.5615.49"); put("113", "113.0.5672.24"); put("114", "114.0.5735.16"); + put("115", "115.0.5790.170"); + put("116", "116.0.5845.96"); + put("117", "117.0.5938.149"); + put("118", "118.0.5993.70"); + put("119", "119.0.6045.105"); + put("120", "120.0.6099.71"); } }; diff --git a/src/main/java/org/cloud/sonic/agent/tools/file/FileTool.java b/src/main/java/org/cloud/sonic/agent/tools/file/FileTool.java index d45decda..404f6286 100755 --- a/src/main/java/org/cloud/sonic/agent/tools/file/FileTool.java +++ b/src/main/java/org/cloud/sonic/agent/tools/file/FileTool.java @@ -55,7 +55,16 @@ public static void zip(ZipOutputStream out, File f, String base) throws IOExcept } } - public static File unZipChromeDriver(File source, String version) { + /** + * 解压缩下载完成的chromeDriver.zip文件 + * + * @param source 原始的下载临时文件 + * @param version 完整的chrome版本 + * @param greaterThen114 是否>=115(大于115的场景下,使用的是google官方Chrome for Testing (CfT)下载路径) + * @param systemName 系统类型(大于115的场景下,判断产物文件会使用到) + * @return chromeDriver文件 + */ + public static File unZipChromeDriver(File source, String version, boolean greaterThen114, String systemName) { int BUFFER = 2048; File webview = new File("webview"); if (!webview.exists()) { @@ -73,7 +82,11 @@ public static File unZipChromeDriver(File source, String version) { while (emu.hasMoreElements()) { ZipEntry entry = (ZipEntry) emu.nextElement(); BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry)); - if (entry.getName().equals(tail)) { + // >=115之后的版本,entry.name字段有变更,带上了系统类型 + final String targetFileName = greaterThen114 ? + String.format("chromedriver-%s/%s", systemName, tail) + : tail; + if (entry.getName().equals(targetFileName)) { String fileName = version + "_" + tail; File file = new File(webview + File.separator + fileName); File parent = file.getParentFile();