英文:
Playwright tests are running slow
问题
我正在将我们的测试从Selenium迁移到Playwright。Playwright吸引我的一点是据说运行速度更快,但我发现情况并非如此。我想知道是否有可能我陷入了某种可以轻松避免的困境!
我创建了以下测试,以减少我可能做的一些愚蠢的事情使它们变得很慢的可能性:
[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/");
}
这个测试在无头模式下大约需要8秒才能运行,正如你所看到的,它基本上什么都没做。当与其他5个测试并行运行时,运行时间增加到超过30秒!比我们的Selenium测试还要慢。
我知道Playwright应该很快,是否有一些设置或其他东西我应该查看?!
提前感谢!
英文:
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!
答案1
得分: 2
Playwright通常会在运行测试时下载所需的驱动程序。
检查Playwright是否只在每次测试运行时执行一次,而不是每次测试都执行。
英文:
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.
答案2
得分: 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论