Async::WebDriverSourceAsyncWebDriverInstallerChromeInstallation

class Installation

Represents a Chrome for Testing installation on disk, and provides class-level methods for resolving, locating, and downloading installations.

Installations are stored under the cache_path directory, organised as:

{cache_path}/{platform}/{version}/
  chrome/       ← extracted chrome zip contents
  chromedriver/ ← extracted chromedriver zip contents

Channel names (e.g. stable) are stored as symlinks pointing at the specific version directory, so that Async::WebDriver::Installer::Chrome::Installation.find can resolve them without hitting the network. Async::WebDriver::Installer::Chrome::Installation.install always re-checks the API and updates the symlink if the channel has moved on to a newer version.

Definitions

def self.install(version, cache_path:)

Look up an existing installation, or download and install a fresh one.

For channel specifiers (:stable, :beta, etc.), always hits the Chrome for Testing API to resolve the current version, downloads if needed, and updates the channel symlink. For exact versions, checks the local cache only.

Signature

parameter version Symbol | String

Channel or version specifier.

parameter cache_path String

Root of the cache directory.

returns Installation

Implementation

def self.install(version, cache_path:)
	platform = Platform.current
	release = Releases.resolve(version, platform)
	
	unless installation = find(release[:version], platform, cache_path: cache_path)
		Console.info(self, "Installing Chrome for Testing #{release[:version]}...", platform: platform)
		
		dir = installation_dir(release[:version], platform, cache_path: cache_path)
		FileUtils.mkdir_p(dir)
		
		begin
			download_and_extract(release[:chrome_url], File.join(dir, "chrome"))
			download_and_extract(release[:chromedriver_url], File.join(dir, "chromedriver"))
			
			installation = find(release[:version], platform, cache_path: cache_path) or
				raise "Installation failed: binaries not found after extraction"
			
			Console.info(self, "Installed Chrome for Testing #{release[:version]}.", platform: platform)
		rescue
			FileUtils.rm_rf(dir)
			raise
		end
	end
	
	# Update the channel symlink so subsequent find(:stable) calls
	# resolve locally without a network request.
	if channel = channel_name(version)
		update_channel_symlink(channel, release[:version], platform, cache_path: cache_path)
	end
	
	return installation
end

def self.find(version, platform, cache_path:)

Find an already-installed version or channel, without hitting the network.

For channel names (:stable, "stable", etc.), resolves the local symlink. For exact versions, checks the installation directory directly.

Signature

parameter version Symbol | String

Channel or exact version string.

parameter platform String

Platform string, e.g. "mac-arm64".

parameter cache_path String

Root of the cache directory.

returns Installation | Nil

Implementation

def self.find(version, platform, cache_path:)
	if channel = channel_name(version)
		find_channel(channel, platform, cache_path: cache_path)
	else
		find_version(version, platform, cache_path: cache_path)
	end
end

def initialize(browser_path:, driver_path:, version:, platform:)

Signature

parameter browser_path String

Absolute path to the Chrome browser executable.

parameter driver_path String

Absolute path to the chromedriver executable.

parameter version String

Exact version string.

parameter platform String

Platform string.

Implementation

def initialize(browser_path:, driver_path:, version:, platform:)
	@browser_path = browser_path
	@driver_path = driver_path
	@version = version
	@platform = platform
end

attr :browser_path

Signature

attribute String

Absolute path to the Chrome browser executable.

attr :driver_path

Signature

attribute String

Absolute path to the chromedriver executable.

attr :version

Signature

attribute String

Exact installed version, e.g. "148.0.7778.56".

attr :platform

Signature

attribute String

Platform, e.g. "mac-arm64".