Skip to content

feat: accept datetime.timedelta for timeout parameters#3059

Open
Skn0tt wants to merge 1 commit intomicrosoft:mainfrom
Skn0tt:feat/timedelta-timeouts
Open

feat: accept datetime.timedelta for timeout parameters#3059
Skn0tt wants to merge 1 commit intomicrosoft:mainfrom
Skn0tt:feat/timedelta-timeouts

Conversation

@Skn0tt
Copy link
Copy Markdown
Member

@Skn0tt Skn0tt commented Apr 30, 2026

Closes #2600.

Lets users pass datetime.timedelta to any function with a timeout parameter, in addition to a plain float (milliseconds):

from datetime import timedelta

page.click("div", timeout=timedelta(minutes=5))

The codegen widens every timeout: float parameter on the generated public API to Union[float, datetime.timedelta] and converts via a new to_milliseconds helper at the boundary to the impl layer (which keeps using float, so the doc validator stays happy against the JS number type).

The bulk of the diff is regenerated code from ./scripts/update_api.sh.

Closes microsoft#2600.

Lets users pass datetime.timedelta to any function with a timeout
parameter, in addition to a plain float (milliseconds):

    page.click("div", timeout=timedelta(minutes=5))

The codegen widens every `timeout: float` parameter on the generated
public API to `Union[float, datetime.timedelta]` and converts via a
new `to_milliseconds` helper at the boundary to the impl layer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Skn0tt Skn0tt requested a review from dgozman April 30, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: support passing timedelta objects to functions that take a timeout argument

1 participant