Skip to content

Commit

Permalink
docs: testing chrome extension (hardkoded#1296)
Browse files Browse the repository at this point in the history
* testing chrome extension

* Update docfx_project/examples/ChromeExtension.md

Co-Authored-By: Darío Kondratiuk <dariokondratiuk@gmail.com>
  • Loading branch information
Meir017 and kblok committed Oct 8, 2019
1 parent a086ac1 commit b901c22
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docfx_project/examples/ChromeExtension.md
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
}
```
2 changes: 2 additions & 0 deletions docfx_project/examples/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
href: Page.WaitForSelectorAsync.Searching.md
- name: Download and Reuse Chrome from a custom location
href: ReuseChrome.md
- name: How to test a Chrome Extension
href: ChromeExtension.md
- name: Advanced
items:
- name: How to log CDP communication
Expand Down

0 comments on commit b901c22

Please sign in to comment.