3

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!

Florian
  • 1,019
  • 6
  • 22
Keiggo
  • 113
  • 8
  • 1
    Playwright will typically download the drivers needed if they aren't there when you run a test. Just to rule it out, have you checked whether or not it's just doing that _once_ rather than for every test? – Martin Costello Jun 01 '23 at 08:41
  • 1
    Good shout. How would I check this please? – Keiggo Jun 01 '23 at 08:44
  • 1
    @MartinCostello this was the right answer! If you write it as an answer, I can mark it as such. You have my undying gratitude. – Keiggo Jun 01 '23 at 09:37
  • 1
    "When run in parallel with 5 other tests, the run time goes up to over 30 seconds!" Have you checked the CPU load on your machine when it's doing that..? – AKX Jun 01 '23 at 11:15

2 Answers2

2

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.

Martin Costello
  • 9,672
  • 5
  • 60
  • 72
1

Try Recording a Trace

It's hard to suggest anything concrete with the current info provided.

In general, try recording a trace and see which operations are slow.

Vishal Aggarwal
  • 1,929
  • 1
  • 13
  • 23