Closed rasupit closed 1 year ago
@rasupit were you able to get your issues resolved? I was having the same issue, so I followed the advice from @mxschmitt and added: <PlaywrightPlatform>all</PlaywrightPlatform>
, however that only got me to the next line: await using var browser = await playwright.Chromium.LaunchAsync();
at which point I get the error:
Microsoft.Playwright.PlaywrightException: 'Executable doesn't exist at /root/.cache/ms-playwright/chromium-1067/chrome-linux/chrome
Since you now have the driver you can install now the browsers, see here: https://playwright.dev/dotnet/docs/browsers#install-browsers
Thanks @mxschmitt. I'm up and running now!! :) 👍
Looks like you need https://playwright.dev/dotnet/docs/library#bundle-drivers-for-different-platforms
this gets me past the driver not found. I ran into the same error message as @zpertee did but could not figure out how to run the playwright.sh. could this be added inside dockerfile?
There is no need to run the playwright.sh manually. Once you have the PlaywrightPlatform correctly configured, you should be able to just install the browsers and it should all work.
If you want to skip installing the browsers, you can use our recommended Docker image: https://playwright.dev/dotnet/docs/docker
@rasupit FYI, I ended up creating a function like this that I can access when when I pass in a -i argument into my console app:
static void PerformInitialPlaywrightInstall()
{
var exitCode = Microsoft.Playwright.Program.Main(new[] { "install", "--with-deps", "chromium" });
if (exitCode != 0)
{
throw new Exception($"Playwright exited with code {exitCode}");
}
}
And then added this line to my dockerfile: RUN dotnet MyPlaywrightApp.dll -i
. At that point I'm able to do a 1 time install during my docker build process and it seems like that everything works perfectly after that.
@mxschmitt Does the recommended docker image already contain the .net runtime (if so which one(s)) or would I need to install that separately during the build process?
Thanks @zpertee. With the help from @zpertee, I was able to figure out how to install the browser and its dependencies.
I wish there is some good step by step documentation about this process and not just some general documentation describing how to install this through powershell.
For those who struggles on how to setup playwright using dotnet with docker container, I'll leave the sample working project here: https://github.com/rasupit/PlaywrightNet
Context:
Code Snippet c# code:
dockerfile:
Code Snippet: test code is available: https://github.com/rasupit/PlaywrightNet
Describe the bug It appear that the folder linux-x64 is not exists. this foleder is needed because of the program is running inside linux docker
Error Screenshot: