Skip to main content

TimeoutError

  • 继承:[错误]

    ¥extends: [Error]

每当某些操作由于超时而终止时,就会触发 TimeoutError ,例如 Locator.WaitForAsync()BrowserType.LaunchAsync()

¥TimeoutError is emitted whenever certain operations are terminated due to timeout, e.g. Locator.WaitForAsync() or BrowserType.LaunchAsync().

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!");
}