超时错误
- 扩展: [错误]
当某些操作由于超时而终止时,例如 Locator.WaitForAsync() 或 BrowserType.LaunchAsync(),会发出 TimeoutError。
using Microsoft.Playwright;
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
try
{
await page.ClickAsync("text=Example", new() { Timeout = 100 });
}
catch (TimeoutException)
{
Console.WriteLine("Timeout!");
}