TimeoutError
- extends: PlaywrightException
TimeoutError is emitted whenever certain operations are terminated due to timeout, e.g. Locator.waitFor() or BrowserType.launch().
package org.example;
import com.microsoft.playwright.*;
public class TimeoutErrorExample {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.firefox().launch();
BrowserContext context = browser.newContext();
Page page = context.newPage();
try {
page.locator("text=Example").click(new Locator.ClickOptions().setTimeout(100));
} catch (TimeoutError e) {
System.out.println("Timeout!");
}
}
}
}