I am not able to run azure function which calls the playwright test after I publish it to the Azure cloud.
The exception is following
Playwright Test or Playwright was just installed or updated.
║ ║ Please run the following command to download new browsers: ║ ║
║ ║ playwright install ║ ║
║ ║ <3 Playwright Team ║
The issue is that I don't know how to run playwright install.
There is some remote build possibility, but the documentation does not contains details.
So I tried following
- Copy chrome browser
%USERPROFILE%\AppData\Local\ms-playwright\chrome-wininto the project folder. - Attach chrome-win folder into the project.
- Update
.csprojso the chrome browser will be in output directory and output zip
<ItemGroup>
<Content Include="chrome-win\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
- Update executable path in playwright
await using var browser = await playwright.Chromium.LaunchAsync(new() { ExecutablePath = "chrome-win/chrome.exe"});
Locally, it is working fine. Zip Deploy to Azure is also successful. But when the Azure function is triggered, it throws some unknown exception
Result: Failure Exception: System.AggregateException: One or more errors occurred. (spawn UNKNOWN =========================== logs =========================== <launching> chrome-win/chrome.exe --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --user-data-dir=C:\local\Temp\playwright_chromiumdev_profile-rw44Ph --remote-debugging-pipe --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --no-startup-window ============================================================) ---> Microsoft.Playwright.PlaywrightException: spawn UNKNOWN
I just don't want to believe that I have to rewrite everything into JavaScript because of one line command in the terminal
Is it possible to switch to Linux OS with functions written in .NET and use browser installed via npm install playwright? The .NET is cross platform now, so it might work?
Has anyone managed to get this up and running?