Skip to content

Download and Reuse Chrome from a custom location

Contributors: Bilal Durrani

You want to download Chrome in a custom folder and you want to reuse Chrome from a location where it was previously downloaded instead of from the default location.

Use BrowserFetcherOptions to specify the full path for where to download Chrome.

var downloadPath = "/Users/dario/chrome";
var browserFetcherOptions = new BrowserFetcherOptions { Path = downloadPath };
var browserFetcher = new BrowserFetcher(browserFetcherOptions);
var installedBrowser = await browserFetcher.DownloadAsync();

snippet source | anchor

Use Puppeteer.LaunchAsync() with LaunchOptions with the LaunchOptions.ExecutablePath property set to the fully qualified path to the Chrome executable.

var options = new LaunchOptions { Headless = true, ExecutablePath = installedBrowser.GetExecutablePath() };
await using var browser = await Puppeteer.LaunchAsync(options);
await using var page = await browser.NewPageAsync();
await page.GoToAsync("about:blank");

Made with love by Dario Kondratiuk