playwright-python icon indicating copy to clipboard operation
playwright-python copied to clipboard

[Feature] More `Exception` types

Open DetachHead opened this issue 3 years ago • 1 comments

Currently playwright says playwright._impl._api_types.TimeoutError or playwright._impl._api_types.Error, could you please add a lot more errors such as NavigationError, SelectorNotFoundError etc.

Use case is that I want to handle specific errors in try/except statements like so:

try:
    page.click("asdf")
except SelectorNotFoundError:
    print("selector not found")

DetachHead avatar Jul 12 '22 06:07 DetachHead

As a work around for now, you can convert the thrown exception to a string and match based on its contents.

rwoll avatar Jul 12 '22 07:07 rwoll

Closing for now since this is not planned in the near future.

mxschmitt avatar Oct 23 '23 21:10 mxschmitt