Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #414 from twilio/improve-chromedriver-version-sele…
Browse files Browse the repository at this point in the history
…ction

Improved ChromeDriver version selection
  • Loading branch information
vania-pooh authored Jul 27, 2021
2 parents 7264d0b + b63ac6a commit 5000a93
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions build/chrome.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 5000a93

Please sign in to comment.