From 88a3f4dbc689ddb1067efb7e1aa231b0651f2bd0 Mon Sep 17 00:00:00 2001 From: Ronald Pijnacker Date: Tue, 15 Jun 2021 14:58:05 +0200 Subject: [PATCH] Fix ChromeDriver version detection --- .../ChromeDriverRelease.java | 20 +++++++++++++++++-- .../WebDriverReleaseManagerTest.java | 4 ++-- .../WebDriverReleaseTest.java | 6 +++--- .../fixtures/chromedriver_release_version.txt | 1 + 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 SeleniumGridExtras/src/test/resources/fixtures/chromedriver_release_version.txt diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/downloader/webdriverreleasemanager/ChromeDriverRelease.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/downloader/webdriverreleasemanager/ChromeDriverRelease.java index 934f4fd3..6b0ffe9f 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/downloader/webdriverreleasemanager/ChromeDriverRelease.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/downloader/webdriverreleasemanager/ChromeDriverRelease.java @@ -6,19 +6,22 @@ public class ChromeDriverRelease extends WebDriverRelease { + private int buildVersion; + public ChromeDriverRelease(String input) { super(input); - Matcher m = Pattern.compile("(\\d+)\\.(\\d+)").matcher(input); + Matcher m = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)").matcher(input); if (m.find()){ setMajorVersion(Integer.valueOf(m.group(1))); setMinorVersion(Integer.valueOf(m.group(2))); + setBuildVersion(Integer.valueOf(m.group(3))); + setPatchVersion(Integer.valueOf(m.group(4))); } setName("chromedriver"); setRelativePath("index.html?path=" + getPrettyPrintVersion(".") + "/"); - } public String getPrettyPrintVersion(String separator){ @@ -27,7 +30,20 @@ public String getPrettyPrintVersion(String separator){ stringBuilder.append(getMajorVersion()); stringBuilder.append(separator); stringBuilder.append(getMinorVersion()); + stringBuilder.append(separator); + stringBuilder.append(getBuildVersion()); + stringBuilder.append(separator); + stringBuilder.append(getPatchVersion()); return stringBuilder.toString(); } + + public int getBuildVersion() { + return buildVersion; + } + + public void setBuildVersion(int buildVersion) { + this.buildVersion = buildVersion; + } + } diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/WebDriverReleaseManagerTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/WebDriverReleaseManagerTest.java index a0319a59..679ce968 100644 --- a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/WebDriverReleaseManagerTest.java +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/WebDriverReleaseManagerTest.java @@ -18,7 +18,7 @@ public class WebDriverReleaseManagerTest { @Before public void setUp() throws Exception { URL webDriverAndIEDriverURL = ClassLoader.getSystemResource("fixtures/selenium_release_manifest.xml"); - URL chromeDriverVersionURL = ClassLoader.getSystemResource("fixtures/selenium_release_version.txt"); + URL chromeDriverVersionURL = ClassLoader.getSystemResource("fixtures/chromedriver_release_version.txt"); URL marionetteDriverVersionURL = ClassLoader.getSystemResource("fixtures/selenium_release_version.txt"); releaseManager = new WebDriverReleaseManager(webDriverAndIEDriverURL, chromeDriverVersionURL, marionetteDriverVersionURL); } @@ -33,7 +33,7 @@ public void testReleaseCounts() throws Exception { public void testGetLatestVersion() throws Exception { assertEquals("2.41.0", releaseManager.getWedriverLatestVersion().getPrettyPrintVersion(".")); assertEquals("2.41.0", releaseManager.getIeDriverLatestVersion().getPrettyPrintVersion(".")); - assertEquals("2.10", releaseManager.getChromeDriverLatestVersion().getPrettyPrintVersion(".")); + assertEquals("2.10.13.42", releaseManager.getChromeDriverLatestVersion().getPrettyPrintVersion(".")); } @Test diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/webdriverreleasemanager/WebDriverReleaseTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/webdriverreleasemanager/WebDriverReleaseTest.java index ddfcfdd9..d5be3e7c 100644 --- a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/webdriverreleasemanager/WebDriverReleaseTest.java +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/webdriverreleasemanager/WebDriverReleaseTest.java @@ -88,11 +88,11 @@ public void testComparableVersion() throws Exception{ @Test public void testChromeDriverRelease() throws Exception{ - WebDriverRelease chromeRelease = new ChromeDriverRelease("2.10"); + WebDriverRelease chromeRelease = new ChromeDriverRelease("2.10.13.42"); - assertEquals("2.10", chromeRelease.getPrettyPrintVersion(".")); + assertEquals("2.10.13.42", chromeRelease.getPrettyPrintVersion(".")); assertEquals("chromedriver", chromeRelease.getName()); - assertEquals("index.html?path=2.10/", chromeRelease.getRelativePath()); + assertEquals("index.html?path=2.10.13.42/", chromeRelease.getRelativePath()); } diff --git a/SeleniumGridExtras/src/test/resources/fixtures/chromedriver_release_version.txt b/SeleniumGridExtras/src/test/resources/fixtures/chromedriver_release_version.txt new file mode 100644 index 00000000..8c142f5c --- /dev/null +++ b/SeleniumGridExtras/src/test/resources/fixtures/chromedriver_release_version.txt @@ -0,0 +1 @@ +2.10.13.42 \ No newline at end of file