forked from hardkoded/puppeteer-sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: testing chrome extension (hardkoded#1296)
* testing chrome extension * Update docfx_project/examples/ChromeExtension.md Co-Authored-By: Darío Kondratiuk <dariokondratiuk@gmail.com>
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# How to test a Chrome Extension | ||
_Contributors: [Meir Blachman](https://github.com/meir017)_ | ||
|
||
## Problem | ||
|
||
You need to test a chrome extension | ||
|
||
## Solution | ||
|
||
Use `Puppeteer.LaunchAsync` passing arguments specifying to load your extension. | ||
|
||
```cs | ||
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision); | ||
|
||
var pathToExtension = "path/to/extension"; | ||
var launhcOptions = new LaunhcOptions() | ||
{ | ||
Headless = false, | ||
Args = new [] | ||
{ | ||
$"--disable-extensions-except={pathToExtension}", | ||
$"--load-extension=${pathToExtension}" | ||
} | ||
}; | ||
|
||
using (var browser = await Puppeteer.LaunchAsync(launchOptions)) | ||
using (var page = await browser.NewPageAsync()) | ||
{ | ||
// test your extension here | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters