selenium-webdriverremotewebdriverplaywright-dotnet

How do I run Playwright test with C# backend on Mac?


I have converted a test suite from Selenium to Playwright. This suite tests on a Windows PC using Chrome and Edge browsers. This suite is written in Visual Studio with C#, Playwright, Reqnroll and MSTest.

I am now looking at converting our Mac/Safari test suite also (this is still in Selenium). This test suite runs the tests on a Mac Mini which is located in my home office. The tests run against the Safari browser and I am not sure how to get going on this.

We are using Selenium RemoteWebDriver for these tests:

protected static RemoteWebDriver Driver { get; set; } = null;

This is my BeforeScenario code:

var options = new SafariOptions
{
    PageLoadStrategy = PageLoadStrategy.Normal
};
var macMiniIP = "http://00.000.0.00:4444/wd/hub";
Driver = new RemoteWebDriver(new Uri(macMiniIP), options);
Driver.Manage().Window.Maximize();

This all works very well in Selenium and the Safari browser loads in good time ready for the tests but can anyone point me to a good working example on how to achieve this in Playwright?


Solution

  • Playwright doesn't work with Safari, so you can't do this. It does support WebKit, which is similar: https://playwright.dev/docs/browsers#webkit

    You are using RemoteWebDriver, which connects to a Selenium Grid server. Playwright doesn't have its own remote server capabilities, but there is (experimental) support for running Playwright tests using Selenium Grid: https://playwright.dev/docs/selenium-grid

    However, this only works for Google Chrome/Chromium and Microsoft Edge (since they support CDP).