I have a skill for the Amazon Echo. The lambda function is written in C#/.Net Core, and hosted on AWS. I now need to extend it with functionality that uses PuppeteerSharp. My first problem with this was that it downloads chromium and puts it in your application's directory by default. This gave me an error, as the filesystem is read only. I then tried the package HeadlessChromium.Puppeteer.Lambda.Dotnet, but my resulting skill was too large to upload as a lambda function, because it now had chromium embedded.
I'm now trying to override the default puppeteer downloadpath, using a BrowserFetchOption. This allows me to download chromium on AWS to the system temp path, but then Puppeteer can't find it. I need to add ExecutablePath to the LaunchOptions object when I try to launch puppeteer. I've tested this locally under windows and it works, I now just need to write some general code to find the chromium executable under AWS.
- Is there a better way than searching for either chrome or chrome.exe under my download path (I need it to run under windows as well as AWS for the unit tests)? It feels like if Puppeteer provides this pair of options then there must be a better way to use them?
- Is there a better way to use Puppeteer in a lambda function than what I'm attempting?
Here is the windows code that is currently working, with the chrome path hard coded:
string cpath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "chromium");
var bfopt = new BrowserFetcherOptions() { Path = cpath };
await new BrowserFetcher(bfopt).DownloadAsync(BrowserFetcher.DefaultRevision);
var browser = await Puppeteer.LaunchAsync(new LaunchOptions {
ExecutablePath=System.IO.Path.Combine(cpath, "Win64-674921\\chrome-win\\chrome.exe"),
Headless = true
});