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

[Feature]Route&unroute can be made into contextmanagement

Open gcil125 opened this issue 2 years ago • 0 comments

from contextlib import contextmanager


@contextmanager
def expect_route(url, handle, *, times):
    page.route(url, handle, times=times)
    yield
    page.unroute(url, handle)



with expect_route(url, handle) as route_info:
        page.click(xxxx)

I hope that after using route to listen for a click event, I can immediately log off the listening

gcil125 avatar Mar 07 '23 08:03 gcil125