Automating Microsoft Edge with Puppeteer-Sharp

Darío Kondratiuk - Apr 23 '19 - - Dev Community

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

. . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player