Skip to content

Commit

Permalink
Fix ChromeDriver version detection
Browse files Browse the repository at this point in the history
  • Loading branch information
rhpijnacker-philips committed Jun 15, 2021
1 parent 44c7dbf commit 88a3f4d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.10.13.42

0 comments on commit 88a3f4d

Please sign in to comment.