英文:
Playwright opens cmd
问题
当我在C#中运行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:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论