Automating Microsoft Edge with Puppeteer-Sharp
Darío Kondratiuk

Darío Kondratiuk @hardkoded

About: Microsoft MVP - .NET Developer with 15+ years working on web projects.

Joined:
Feb 24, 2017

Automating Microsoft Edge with Puppeteer-Sharp

Publish Date: Apr 23 '19
11 3

As you may have heard, Microsoft made available to the public its Chromium-powered Edge browser. Maybe this question won't qualify as technical interview question but:

If Puppeteer-Sharp automates Chromium, and Microsoft Edge (insider) is powered by chromium, that would mean that...

Idea

When you call Puppeteer.LaunchAsync, one of the values you can set in the LaunchOptions is the ExecutablePath.

So, what would happen if we launch Puppeteer passing our Microsoft Edge browser path?



var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
    Headless = true,
    ExecutablePath = "C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe"
});


Enter fullscreen mode Exit fullscreen mode

Let's write a super simple example:



var browserOptions = new LaunchOptions
{
    Headless = false,
    ExecutablePath = "C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe"
};

var browser = await Puppeteer.LaunchAsync(browserOptions);
var page = await browser.NewPageAsync();

await page.SetContentAsync("<div>Testing</div>");


Enter fullscreen mode Exit fullscreen mode

Voilà!

demo running

And after a few tweaks in puppeteer-sharp, and one similar change in puppeteer, we managed to get all tests running using Microsoft Edge!

tests running

So we can say that Puppeteer-Sharp v1.14 is fully compatible with Microsoft Edge Insider version 75.0.131.0.

Yeah

Don't stop coding!

Originally posted on harkoded.com

Comments 3 total

  • Vedran Mandić
    Vedran MandićApr 24, 2019

    Congratulations! :-) The miracles of modern browsers (and good software which is well tested.)

  • HeadlessTesting
    HeadlessTestingApr 20, 2020

    Great writeup.

    We've added a similar tutorial on our website to use PuppeteerSharp and MicrosoftEdge via Puppeteer in the cloud: headlesstesting.com/support/start/...

    The advantage is that you do not need to have Microsoft Edge installed on your computer, the browser is running in our cloud. And you can scale your script to use multiple browsers in parallel.

Add comment