Skip to content

[Feature] Document page.route  #2136

@EvanTheB

Description

@EvanTheB

I am having some trouble using page.route within pytest. I think the issue stems from the way the route functions are run. I believe the routing is run in a background thread, and the routes are eventually run inside a coroutine event loop.

Relevant docs:

https://playwright.dev/python/docs/network

https://playwright.dev/python/docs/api/class-route

https://playwright.dev/python/docs/api/class-page#page-route

I think the documentation needs to call out the expected behavior of the route functions clearly:

What happens when a route function throws an exception?

What happens if the route function returns without calling one of the route methods (eg route.fulfill)?

I have observed that in pytest asserting or calling pytest.fail from a route function does not fail the test reliably. I am also observing some other non deterministic behaviour, but I do not have a simple reproduction yet. I think clarity on the above points may help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions