playwright-dotnet: [BUG] Exception thrown when using playwright in a single-file published program
Context:
- Playwright Version: 1.24.1
- Operating System: Windows 10
- .NET version: .NET 6
- Browser: All
- Extra:
Code Snippet
See code to reproduce this bug here: https://github.com/resurge/PlaywrightSingleFilePathError
Describe the bug When publishing a project as single file and running the published executable the following error will be shown:
Unhandled exception. System.ArgumentException: The path is empty. (Parameter 'path')
at System.IO.Path.GetFullPath(String path)
at System.IO.FileInfo..ctor(String originalPath, String fullPath, String fileName, Boolean isNormalized)
at System.IO.FileInfo..ctor(String fileName)
at Microsoft.Playwright.Helpers.Driver.GetExecutablePath() in /_/src/Playwright/Helpers/Driver.cs:line 41
at Microsoft.Playwright.Transport.StdIOTransport.GetProcess() in /_/src/Playwright/Transport/StdIOTransport.cs:line 119
at Microsoft.Playwright.Transport.StdIOTransport..ctor() in /_/src/Playwright/Transport/StdIOTransport.cs:line 44
at Microsoft.Playwright.Playwright.CreateAsync() in /_/src/Playwright/Playwright.cs:line 44
at Program.<Main>$(String[] args) in C:\Users\jeroe\Documents\repos\PlaywrightSingleFilePathError\Program.cs:line 3
at Program.<Main>(String[] args)
I would expect the program to behave the same way as a regular Debug or Release build.
But choosing to publish as a single file causes the behaviour of the executable to change. (And not work)
The following tickets were about the same bug but were closed because of no code to reproduce:
- https://github.com/microsoft/playwright-dotnet/issues/1952
- https://github.com/microsoft/playwright-dotnet/issues/1527
EDIT: Some other issues I found relating to this bug:
- https://github.com/microsoft/playwright-dotnet/issues/1069
Not sure how the solution here works because
Playwright.CreateAsyncdoesn´t accept parameters. - https://github.com/microsoft/playwright-dotnet/issues/1274 This ticket is closed with comment “not supported”, but no reason is given as to why not.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 11
- Comments: 21 (7 by maintainers)
While that seems to be the initial reason Playwright was created it is used for more that that.
I myself use it for scraping or transforming html to PDF. I would like to be able to share a single executable with users instead of having to make a zip file or installer as release.
I agree more with the description that is written in the README of this repo.
(Browser automation in general, not just specifically for testing)
The linked issues show that there is a need for this type of publishing.
EDIT: I found some more tickets about people using it this way, I added them above.
Starting from v1.44 (will be released in 3-4 weeks) this should be fixed: https://github.com/microsoft/playwright-dotnet/pull/2909
Browsers need to be installed via
Microsoft.Playwright.Program.Main(["install"]);Same issue here. We publish a single-file self-contained executable in a docker image, alongside the playwright stuff.
When dealing with docker images that is significantly more convenient and eliminates many dependency problems (which is why it is such a popular approach in the docker world).
But playwright conflicts with that deployment model.
I’ll try to test tomorrow. I actually haven’t worked on the project this was for since the creation of this issue.
You verified it working on your end?
EDIT: Still doesn’t seem to work although I get a clearer error message now.
Same result when publishing self contained or framework dependent.