Skip to content

Commit 0b5761d

Browse files
Merge pull request #52 from testdevlab/Remote
chromedriver get from chromedriver list
2 parents 93c5e8f + 3835514 commit 0b5761d

1 file changed

Lines changed: 28 additions & 35 deletions

File tree

src/main/java/testUI/AndroidUtils/ADBUtils.java

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package testUI.AndroidUtils;
22

33
import org.apache.commons.io.FileUtils;
4+
import org.apache.http.client.methods.CloseableHttpResponse;
5+
import org.apache.http.client.methods.HttpGet;
6+
import org.apache.http.impl.client.CloseableHttpClient;
7+
import org.apache.http.impl.client.HttpClients;
8+
import org.apache.http.util.EntityUtils;
49
import testUI.TestUIConfiguration;
510
import testUI.Utils.TestUIException;
611

@@ -13,6 +18,7 @@
1318

1419
import static testUI.UIUtils.getDevice;
1520
import static testUI.UIUtils.putLog;
21+
import static testUI.Utils.Logger.putLogWarn;
1622

1723
public class ADBUtils {
1824

@@ -373,41 +379,28 @@ private static boolean doesFileExists(String filePath) {
373379
}
374380

375381
private static String getChromedriverVersion(String chromeVersion) {
376-
switch (chromeVersion.split("\\.")[0]) {
377-
case "79":
378-
return "79.0.3945.36";
379-
case "78":
380-
return "78.0.3904.11";
381-
case "77":
382-
return "77.0.3865.10";
383-
case "76":
384-
return "76.0.3809.68";
385-
case "75":
386-
return "75.0.3770.90";
387-
case "74":
388-
return "74.0.3729.6";
389-
case "73":
390-
return "2.46";
391-
case "72":
392-
case "71":
393-
case "70":
394-
case "69":
395-
return "2.44";
396-
case "68":
397-
case "67":
398-
case "66":
399-
return "2.40";
400-
case "65":
401-
case "64":
402-
case "63":
403-
case "62":
404-
return "2.35";
405-
case "61":
406-
case "60":
407-
case "59":
408-
return "2.32";
409-
default:
410-
return "NOT";
382+
String version = chromeVersion.split("\\.")[0] + ".";
383+
String URL = "https://chromedriver.storage.googleapis.com/";
384+
HttpGet get = new HttpGet(URL);
385+
CloseableHttpClient httpClient = HttpClients.createDefault();
386+
String body = "";
387+
try {
388+
CloseableHttpResponse response = httpClient.execute(get);
389+
body = EntityUtils.toString(response.getEntity());
390+
} catch (Exception e) {
391+
putLogWarn("Could not connect to \"https://chromedriver.storage.googleapis.com/\"");
392+
return "80";
393+
}
394+
String chromeDriverVersion = ""; // ToDo it is not pulling the version. I just
395+
String new_chrome_version = "";
396+
for (String text : body.split(version)) {
397+
if (text.contains("/chromedriver_mac64.zip")) {
398+
new_chrome_version =
399+
version + text.split("/chromedriver_mac64\\.zip")[0];
400+
}
401+
if (new_chrome_version.length() < 17)
402+
chromeDriverVersion = new_chrome_version;
411403
}
404+
return chromeDriverVersion;
412405
}
413406
}

0 commit comments

Comments
 (0)