Search code examples
c#automated-testsplaywright

Playwright tests are running slow


I'm in the middle of migrating our tests over from Selenium to Playwright. One of the draws to Playwright is the supposed faster run time, but I am finding that to not be the case. I wonder if I'm stepping into some kind of heffalump trap that could be easily avoided!

I created the following test to reduce the likelihood that some stupid thing I'm doing is grinding them to a halt:

[Test]
public async Task speed_test()
{
    playwright = await Playwright.CreateAsync();
    browser = await playwright.Chromium.LaunchAsync();
    context = await browser.NewContextAsync();
    page = await context.NewPageAsync();

    await page.GotoAsync("https://www.google.co.uk/");
}

This test takes about 8 seconds to run headless and, as you can see, it basically does nothing. When run in parallel with 5 other tests, the run time goes up to over 30 seconds! Slower than our Selenium tests.

I know that Playwright is meant to be fast, are there some settings or something that I should look into?!

Thanks in advance!


Solution

  • Playwright will typically download the drivers needed if they aren't there when you run a test.

    Checked that Playwright is just doing that once rather than for every test.