Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]Route&unroute can be made into contextmanagement #1800

Open
gcil125 opened this issue Mar 7, 2023 · 0 comments
Open

[Feature]Route&unroute can be made into contextmanagement #1800

gcil125 opened this issue Mar 7, 2023 · 0 comments

Comments

@gcil125
Copy link

gcil125 commented Mar 7, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants