launcher

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package launcher provides Chrome browser launching and installation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindSystemChrome

func FindSystemChrome() (string, error)

FindSystemChrome looks for Chrome installed on the system.

func GetCacheDir

func GetCacheDir() (string, error)

GetCacheDir returns the platform-specific cache directory for webpilot.

func GetChromeDir

func GetChromeDir() (string, error)

GetChromeDir returns the directory where Chrome for Testing is installed.

func GetChromePath

func GetChromePath(version string) (string, error)

GetChromePath returns the path to the Chrome executable for the given version. If version is empty, it looks for any installed version.

func IsInstalled

func IsInstalled() bool

IsInstalled checks if Chrome for Testing is already installed.

func Uninstall

func Uninstall() error

Uninstall removes the installed Chrome for Testing.

func Version

func Version() string

Version returns the installed Chrome version, or empty string if not installed.

Types

type Browser

type Browser struct {
	// contains filtered or unexported fields
}

Browser represents a running browser instance.

func Launch

func Launch(ctx context.Context, opts *Options) (*Browser, error)

Launch starts a new Chrome browser with BiDi support.

func LaunchHeadless

func LaunchHeadless(ctx context.Context) (*Browser, error)

LaunchHeadless is a convenience function to launch a headless browser.

func MustLaunch

func MustLaunch(ctx context.Context, opts *Options) *Browser

MustLaunch is like Launch but panics on error.

func (*Browser) Port

func (b *Browser) Port() int

Port returns the debugging port.

func (*Browser) Stop

func (b *Browser) Stop() error

Stop gracefully stops the browser.

func (*Browser) Wait

func (b *Browser) Wait() error

Wait waits for the browser process to exit.

func (*Browser) WebSocketURL

func (b *Browser) WebSocketURL() string

WebSocketURL returns the WebSocket URL for BiDi connection.

type Download

type Download struct {
	Platform string `json:"platform"`
	URL      string `json:"url"`
}

Download represents a download URL for a specific platform.

type InstallResult

type InstallResult struct {
	ChromePath string
	Version    string
}

InstallResult contains the paths to installed binaries.

func Install

func Install() (*InstallResult, error)

Install downloads and installs Chrome for Testing. Returns the path to the installed Chrome executable. Skips download if already installed.

type LastKnownGoodResponse

type LastKnownGoodResponse struct {
	Channels map[string]VersionInfo `json:"channels"`
}

LastKnownGoodResponse represents the API response for last known good versions.

type Options

type Options struct {
	// Headless runs the browser in headless mode.
	Headless bool

	// Port specifies the debugging port. If 0, a random port is used.
	Port int

	// ExecutablePath specifies a custom Chrome executable path.
	ExecutablePath string

	// UserDataDir specifies a custom user data directory.
	// If empty, a temporary directory is used.
	UserDataDir string

	// Args specifies additional command-line arguments.
	Args []string

	// AutoInstall automatically downloads Chrome if not found.
	// Defaults to true.
	AutoInstall *bool
}

Options configures the browser launch.

type Platform

type Platform string

Platform represents a browser download platform.

const (
	PlatformMacArm64 Platform = "mac-arm64"
	PlatformMacX64   Platform = "mac-x64"
	PlatformLinux64  Platform = "linux64"
	PlatformWin32    Platform = "win32"
	PlatformWin64    Platform = "win64"
)

func GetPlatform

func GetPlatform() Platform

GetPlatform returns the current platform string for Chrome for Testing downloads.

type VersionInfo

type VersionInfo struct {
	Version   string                `json:"version"`
	Downloads map[string][]Download `json:"downloads"`
}

VersionInfo represents Chrome for Testing version information.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL