Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Not able to use Playwright on macOS Catalyst #2843

Open
lk-code opened this issue Jan 25, 2024 · 5 comments
Open

[BUG] Not able to use Playwright on macOS Catalyst #2843

lk-code opened this issue Jan 25, 2024 · 5 comments

Comments

@lk-code
Copy link

lk-code commented Jan 25, 2024

System info

  • Playwright Version: 1.41.2
  • Operating System: macOS 14.3
  • Browser: All
  • Other info:

Source code

i use the sample code from playwright on macOS and got an exception at the following line (the logic is in a .NET 8 Class Library):

using var playwright = await Playwright.CreateAsync();
...

EXCEPTION:

Microsoft.Playwright.PlaywrightException: Unknown platform
   at Microsoft.Playwright.Helpers.Driver.GetPath(String driversPath) in /_/src/Playwright/Helpers/Driver.cs:line 119
   at Microsoft.Playwright.Helpers.Driver.GetExecutablePath() in /_/src/Playwright/Helpers/Driver.cs:line 82
   at Microsoft.Playwright.Transport.StdIOTransport.GetProcess(String driverArgs) in /_/src/Playwright/Transport/StdIOTransport.cs:line 116
   at Microsoft.Playwright.Transport.StdIOTransport..ctor() in /_/src/Playwright/Transport/StdIOTransport.cs:line 46
   at Microsoft.Playwright.Playwright.CreateAsync() in /_/src/Playwright/Playwright.cs:line 44
   at ArmyPlanner.Admin.Core.WebsiteParsers.CitadelColorSearch.GetImageUrl(String colorName, CancellationToken cancellationToken) in /Users/larskramer/Projects/lk-code/armyplanner-admin-app/source/ArmyPlanner.Admin.Core/WebsiteParsers/CitadelColorSearch.cs:line 90
   at ArmyPlanner.Admin.Maui.ViewModels.ColorManagement.DetailViewModel.OnColorCodeSearchAsync(CancellationToken cancellationToken) in /Users/larskramer/Projects/lk-code/armyplanner-admin-app/source/ArmyPlanner.Admin.Maui/ViewModels/ColorManagement/DetailViewModel.cs:line 41

I followed the code through the StackTrace and came to a place where basically the string "OSX" is compared with the string "MACCATALYST" and "IOS" and therefore fails. The value "OSX" is set in Driver.cs line 107 and compared with the current platform in the if. In the OperatingSystem.cs file, however, only MACCATALAYST and IOS are checked as described.

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool IsOSPlatform(string platform)
    {
      ArgumentNullException.ThrowIfNull((object) platform, nameof (platform));
      return platform.Equals("MACCATALYST", StringComparison.OrdinalIgnoreCase) || platform.Equals("IOS", StringComparison.OrdinalIgnoreCase);
    }

As soon as the platform names for macOS are used correctly everywhere, the bug is fixed and the "Unknown-Platform" exception no longer occurs :)

@lk-code
Copy link
Author

lk-code commented Jan 25, 2024

In short, Playwright is currently not usable for macOS users :(

@mxschmitt
Copy link
Member

The error gets thrown here:

throw new PlaywrightException("Unknown platform");

We do RuntimeInformation.IsOSPlatform(OSPlatform.OSX) inside, which is for some reason not working on your environment. Which TFM are you using? Are you using net6.0-maccatalyst?

@mxschmitt mxschmitt changed the title [BUG] [BUG] Not able to use Playwright on macOS Catalyst Jan 25, 2024
@mxschmitt mxschmitt transferred this issue from microsoft/playwright Jan 25, 2024
@lk-code
Copy link
Author

lk-code commented Jan 25, 2024

the class library has net8.0 and the app net8.0-maccatalyst.

I know that the exception is thrown there :)

The if statement in line 107 specifies OSX, but behind it are the values MACCATALYST and IOS. This means that the if fails every time. The string comparison is always wrong on macOS.

@cyrilgupta
Copy link

I am experiencing the same issue. I am trying to use this on MacOS in a Blazor MAUI app.

@erodriguezh
Copy link

Here same as @cyrilgupta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants