Skip to content

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

Closed

Description

@gcil125
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

Activity

  1. Skn0tt commented on Apr 30, 2026

    @Skn0tt
    Contributor

    Fixed in #3052.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions