Skip to content

[Bug]: page.wait_for_url doesn't respect page.set_default_timeout #2887

Open
@slafs

Description

@slafs

Version

pytest-playwright==0.7.0 playwright==1.52.0

Steps to reproduce

The following file (e.g. test_wait_for_url.py)

from playwright.sync_api import Page


def test_wait_for_url(page: Page) -> None:
    page.set_default_timeout(5_000)
    page.goto("https://example.com")
    page.wait_for_url("https://foo.bar")

when run via pytest like this:

uvx --with pytest-playwright pytest

fails after ~30 seconds with:

E       playwright._impl._errors.TimeoutError: Timeout 30000ms exceeded.
E       =========================== logs ===========================
E       waiting for navigation to "https://foo.bar" until 'load'
E       ============================================================

not after ~5s as expected when using page.set_default_timeout(5_000).

The docs for the timeout argument on this method suggest this should work.

https://playwright.dev/python/docs/api/class-page#page-wait-for-url-option-timeout

The default value can be changed by using the browser_context.set_default_navigation_timeout(), browser_context.set_default_timeout(), page.set_default_navigation_timeout() or page.set_default_timeout() methods.

Expected behavior

The test should fail after ~5 seconds already.

Actual behavior

The test fails after ~30 seconds.

Additional context

When using set_default_navigation_timeout this works as expected.

Environment

- Operating System: OSX 15.5
- CPU: arm64
- Browser: Chromium
- Python Version: 3.12.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions