Playwright 打开 cmd

huangapple go评论80阅读模式
英文:

Playwright opens cmd

问题

当我在C#中运行Playwright代码时,会打开许多cmd窗口:
Playwright 打开 cmd

这是我使用的代码:

using (var playwright = await Playwright.CreateAsync())
{
    var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions() { Headless = true }).ConfigureAwait(false);
    var browserPageOptions = new BrowserNewPageOptions() { JavaScriptEnabled = true };
    var page = await browser.NewPageAsync(browserPageOptions).ConfigureAwait(false);
    await page.GotoAsync(URL).ConfigureAwait(false);
    await page.WaitForRequestFinishedAsync();
    var SourceCode = await page.ContentAsync().ConfigureAwait(false);
    await page.CloseAsync().ConfigureAwait(false);
    await browser.CloseAsync().ConfigureAwait(false);
}
英文:

When I run a playwright code in C#, it opens up many cmd windows:
Playwright 打开 cmd

This is the code I use:

using (var playwright = await Playwright.CreateAsync())
                    {
        var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions() { Headless = true }).ConfigureAwait(false);
        var browserPageOptions = new BrowserNewPageOptions() { JavaScriptEnabled = true  };
        var page = await browser.NewPageAsync(browserPageOptions).ConfigureAwait(false);
        await page.GotoAsync(URL).ConfigureAwait(false);
        await page.WaitForRequestFinishedAsync();
        var SourceCode = await page.ContentAsync().ConfigureAwait(false);
        await page.CloseAsync().ConfigureAwait(false);
        await browser.CloseAsync().ConfigureAwait(false);

}

答案1

得分: 1

我相信你可能正在运行Playwright版本1.31.0。

这个版本存在一个缺陷,导致cascading cmd windows to appear。这个问题已经在版本1.31.1中得到修复。

英文:

I believe you are probably running Playwright v1.31.0

That had a defect in that caused cascading cmd windows to appear. That has been fixed in v1.31.1

huangapple
  • 本文由 发表于 2023年2月27日 05:18:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/75575064.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定