From b63ac6a57cce6c621b4be9e382a72f90c562ce91 Mon Sep 17 00:00:00 2001 From: Ruben Esteve Date: Mon, 26 Jul 2021 18:16:55 +0200 Subject: [PATCH] Improved ChromeDriver version selection --- build/chrome.go | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/build/chrome.go b/build/chrome.go index 7a4e17ad0..53ce4b2ce 100644 --- a/build/chrome.go +++ b/build/chrome.go @@ -143,29 +143,31 @@ func (c *Chrome) getLatestChromeDriver(baseUrl string, pkgVersion string) (strin return string(data), nil } - switch c.BrowserChannel { - case "dev": - chromeMajorVersion, err := strconv.Atoi(majorVersion(pkgVersion)) - if err != nil { - return "", fmt.Errorf("chrome major version: %v", err) + if c.BrowserChannel != "dev" { + chromeBuildVersion := buildVersion(pkgVersion) + u := baseUrl + fmt.Sprintf("LATEST_RELEASE_%s", chromeBuildVersion) + v, err := fetchVersion(u) + if err == nil { + return v, nil } - u := baseUrl + fmt.Sprintf("LATEST_RELEASE_%d", chromeMajorVersion) + } + + chromeMajorVersion, err := strconv.Atoi(majorVersion(pkgVersion)) + if err != nil { + return "", fmt.Errorf("chrome major version: %v", err) + } + u := baseUrl + fmt.Sprintf("LATEST_RELEASE_%d", chromeMajorVersion) + v, err := fetchVersion(u) + if err == nil { + return v, nil + } else { + previousChromeMajorVersion := chromeMajorVersion - 1 + u = baseUrl + fmt.Sprintf("LATEST_RELEASE_%d", previousChromeMajorVersion) v, err := fetchVersion(u) if err == nil { return v, nil } else { - previousChromeMajorVersion := chromeMajorVersion - 1 - u = baseUrl + fmt.Sprintf("LATEST_RELEASE_%d", previousChromeMajorVersion) - v, err := fetchVersion(u) - if err == nil { - return v, nil - } else { - return "", errors.New("could not find compatible chromedriver") - } + return "", errors.New("could not find compatible chromedriver") } - default: - chromeBuildVersion := buildVersion(pkgVersion) - u := baseUrl + fmt.Sprintf("LATEST_RELEASE_%s", chromeBuildVersion) - return fetchVersion(u) } }