From 3a2a395c4427aba71f296c12f4d91a9b861035d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Kondratiuk?= Date: Thu, 23 May 2024 16:48:28 -0300 Subject: [PATCH] Fix reuse chrome docs (#2646) * Fix reuse chrome docs * Docs changes --------- Co-authored-by: GitHub Action --- docfx_project/examples/DownloadFetcher.Download.md | 2 +- docfx_project/examples/ReuseChrome.md | 8 ++++++-- .../Browsers/Chrome/ChromeDataTests.cs | 10 ++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/docfx_project/examples/DownloadFetcher.Download.md b/docfx_project/examples/DownloadFetcher.Download.md index 9543c9cdc..ccad919c7 100644 --- a/docfx_project/examples/DownloadFetcher.Download.md +++ b/docfx_project/examples/DownloadFetcher.Download.md @@ -51,6 +51,6 @@ await using (var browser = await Puppeteer.LaunchAsync(new() Console.WriteLine("Export completed"); } ``` -snippet source | anchor +snippet source | anchor ``` diff --git a/docfx_project/examples/ReuseChrome.md b/docfx_project/examples/ReuseChrome.md index 349dd6f2b..1275cd67d 100644 --- a/docfx_project/examples/ReuseChrome.md +++ b/docfx_project/examples/ReuseChrome.md @@ -11,12 +11,16 @@ from a location where it was previously downloaded instead of from the default l Use `BrowserFetcherOptions` to specify the full path for where to download Chrome. -``` + + +```cs var downloadPath = "/Users/dario/chrome"; var browserFetcherOptions = new BrowserFetcherOptions { Path = downloadPath }; -using var browserFetcher = new BrowserFetcher(browserFetcherOptions); +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. diff --git a/lib/PuppeteerSharp.Tests/Browsers/Chrome/ChromeDataTests.cs b/lib/PuppeteerSharp.Tests/Browsers/Chrome/ChromeDataTests.cs index 07adc5e01..123de025d 100644 --- a/lib/PuppeteerSharp.Tests/Browsers/Chrome/ChromeDataTests.cs +++ b/lib/PuppeteerSharp.Tests/Browsers/Chrome/ChromeDataTests.cs @@ -9,6 +9,16 @@ namespace PuppeteerSharp.Tests.Browsers.Chrome { public class ChromeDataTests { + public async Task ReuseChromeExample() + { + #region ReuseChromeExample + var downloadPath = "/Users/dario/chrome"; + var browserFetcherOptions = new BrowserFetcherOptions { Path = downloadPath }; + var browserFetcher = new BrowserFetcher(browserFetcherOptions); + var installedBrowser = await browserFetcher.DownloadAsync(); + #endregion + } + public async Task Usage() { #region CustomVersionsExample