using Microsoft.Playwright;
class Program
{
public static async Task Main()
{
Console.WriteLine("打开浏览器..1");
using var playwright = await Playwright.CreateAsync();
//
Console.WriteLine("打开浏览器..2");
await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
{
Headless = false,
// SlowMo = 50,
});//打开很慢
//await using var browser = await playwright.Chromium.LaunchAsync(); //默认无头方式也打开很慢
Console.WriteLine("ok..");
}
}
visual studio 2022 调试时太慢,要20秒左右才能打开浏览器 ms-playwright\chromium-1000
参考的官方例子 https://playwright.dev/dotnet/docs/intro
```python
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
print('Hi1')
#browser = p.webkit.launch()
browser = p.webkit.launch(headless = False, slow_mo = 50)
print('Hi2,用c# python测试过,launch依旧很慢,要20秒,手动打开浏览器只需要1秒')
page = browser.new_page()
page.goto("http://www.so.com/")
page.screenshot(path="example.png")
browser.close()
用c# python测试过,launch依旧很慢,要20秒,手动打开浏览器只需要1秒'
请问什么原因呢?谢谢。