Skip to content

Commit 1e8f23b

Browse files
committed
chore: roll to 1.62.0
roll the driver to `1.62.0` and regenerate the sync and async APIs from the `v1.62.0` docs upstream reverted the `routeFromHar` `interceptAPIRequests` option in `1.62`, so drop the matching `intercept_api_requests` parameter along with `HarRouter.add_api_request_route` and the tests covering it
1 parent 9a10128 commit 1e8f23b

10 files changed

Lines changed: 39 additions & 148 deletions

File tree

DRIVER_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.62.0-alpha-2026-07-16
1+
1.62.0

NODE_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24.18.0
1+
24.18.1

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
44

55
| | Linux | macOS | Windows |
66
| :--- | :---: | :---: | :---: |
7-
| Chromium <!-- GEN:chromium-version -->151.0.7922.19<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->151.0.7922.34<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->26.5<!-- GEN:stop --> ||||
9-
| Firefox <!-- GEN:firefox-version -->152.0.4<!-- GEN:stop --> ||||
9+
| Firefox <!-- GEN:firefox-version -->153.0<!-- GEN:stop --> ||||
1010

1111
## Documentation
1212

playwright/_impl/_browser_context.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@ async def route_from_har(
499499
update: bool = None,
500500
updateContent: Literal["attach", "embed"] = None,
501501
updateMode: HarMode = None,
502-
interceptAPIRequests: bool = None,
503502
) -> None:
504503
if update:
505504
await self._tracing._record_into_har(
@@ -518,8 +517,6 @@ async def route_from_har(
518517
)
519518
self._har_routers.append(router)
520519
await router.add_context_route(self)
521-
if interceptAPIRequests:
522-
await router.add_api_request_route(self)
523520

524521
async def _update_interception_patterns(self) -> None:
525522
patterns = RouteHandler.prepare_interception_patterns(self._routes)

playwright/_impl/_har_router.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
# limitations under the License.
1414
import asyncio
1515
import base64
16-
import re
17-
from typing import TYPE_CHECKING, List, Optional, Tuple, cast
16+
from typing import TYPE_CHECKING, Optional, cast
1817

1918
from playwright._impl._api_structures import HeadersArray
2019
from playwright._impl._helper import (
2120
HarLookupResult,
2221
RouteFromHarNotFoundPolicy,
2322
URLMatch,
24-
escape_regex_flags,
2523
)
2624
from playwright._impl._local_utils import LocalUtils
2725

@@ -43,7 +41,6 @@ def __init__(
4341
self._har_id: str = har_id
4442
self._not_found_action: RouteFromHarNotFoundPolicy = not_found_action
4543
self._options_url_match: Optional[URLMatch] = url_matcher
46-
self._api_request_registrations: List[Tuple["BrowserContext", str]] = []
4744

4845
@staticmethod
4946
async def create(
@@ -119,30 +116,7 @@ async def add_page_route(self, page: "Page") -> None:
119116
handler=lambda route, _: asyncio.create_task(self._handle(route)),
120117
)
121118

122-
async def add_api_request_route(self, context: "BrowserContext") -> None:
123-
url_match = self._options_url_match
124-
params: dict = {
125-
"harId": self._har_id,
126-
"notFound": self._not_found_action,
127-
}
128-
if isinstance(url_match, str):
129-
params["urlGlob"] = url_match
130-
elif isinstance(url_match, re.Pattern):
131-
params["urlRegexSource"] = url_match.pattern
132-
params["urlRegexFlags"] = escape_regex_flags(url_match)
133-
result = await context._channel.send_return_as_dict(
134-
"routeAPIRequestsFromHar", None, params
135-
)
136-
self._api_request_registrations.append((context, result["registrationId"]))
137-
138119
def dispose(self) -> None:
139-
for context, registration_id in self._api_request_registrations:
140-
context._channel.send_may_fail(
141-
"unrouteAPIRequestsFromHar",
142-
None,
143-
{"registrationId": registration_id},
144-
)
145-
self._api_request_registrations = []
146120
self._local_utils._channel.send_may_fail(
147121
"harClose", None, {"harId": self._har_id}
148122
)

playwright/async_api/_generated.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7240,7 +7240,7 @@ async def install(
72407240
Parameters
72417241
----------
72427242
time : Union[datetime.datetime, float, str, None]
7243-
Time to initialize with, current system time by default.
7243+
Time to initialize with, current system time by default. Numeric values are Unix time in seconds.
72447244
"""
72457245

72467246
return mapping.from_maybe_impl(await self._impl_obj.install(time=time))
@@ -7299,7 +7299,7 @@ async def pause_at(self, time: typing.Union[float, str, datetime.datetime]) -> N
72997299
Parameters
73007300
----------
73017301
time : Union[datetime.datetime, float, str]
7302-
Time to pause at.
7302+
Time to pause at. Numeric values are Unix time in seconds.
73037303
"""
73047304

73057305
return mapping.from_maybe_impl(await self._impl_obj.pause_at(time=time))
@@ -7354,7 +7354,7 @@ async def set_fixed_time(
73547354
Parameters
73557355
----------
73567356
time : Union[datetime.datetime, float, str]
7357-
Time to be set.
7357+
Time to be set. Numeric values are Unix time in seconds.
73587358
"""
73597359

73607360
return mapping.from_maybe_impl(await self._impl_obj.set_fixed_time(time=time))
@@ -7378,7 +7378,7 @@ async def set_system_time(
73787378
Parameters
73797379
----------
73807380
time : Union[datetime.datetime, float, str]
7381-
Time to be set.
7381+
Time to be set. Numeric values are Unix time in seconds.
73827382
"""
73837383

73847384
return mapping.from_maybe_impl(await self._impl_obj.set_system_time(time=time))
@@ -10254,6 +10254,12 @@ async def go_back(
1025410254

1025510255
Navigate to the previous page in history.
1025610256

10257+
**NOTE** **Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the
10258+
Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on
10259+
network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using
10260+
`page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized
10261+
`Page` state.
10262+
1025710263
Parameters
1025810264
----------
1025910265
timeout : Union[float, None]
@@ -10296,6 +10302,12 @@ async def go_forward(
1029610302

1029710303
Navigate to the next page in history.
1029810304

10305+
**NOTE** **Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the
10306+
Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on
10307+
network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using
10308+
`page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized
10309+
`Page` state.
10310+
1029910311
Parameters
1030010312
----------
1030110313
timeout : Union[float, None]
@@ -15092,7 +15104,6 @@ async def route_from_har(
1509215104
update: typing.Optional[bool] = None,
1509315105
update_content: typing.Optional[Literal["attach", "embed"]] = None,
1509415106
update_mode: typing.Optional[Literal["full", "minimal"]] = None,
15095-
intercept_api_requests: typing.Optional[bool] = None,
1509615107
) -> None:
1509715108
"""BrowserContext.route_from_har
1509815109

@@ -15126,10 +15137,6 @@ async def route_from_har(
1512615137
When set to `minimal`, only record information necessary for routing from HAR. This omits sizes, timing, page,
1512715138
cookies, security and other types of HAR information that are not used when replaying from HAR. Defaults to
1512815139
`minimal`.
15129-
intercept_api_requests : Union[bool, None]
15130-
If set to `true`, requests made via `APIRequestContext` (such as `browser_context.request` or
15131-
`page.request`) are also served from the HAR file. By default these requests are sent to the network,
15132-
matching the behavior prior to v1.62. Defaults to `false` for backward compatibility.
1513315140
"""
1513415141

1513515142
return mapping.from_maybe_impl(
@@ -15140,7 +15147,6 @@ async def route_from_har(
1514015147
update=update,
1514115148
updateContent=update_content,
1514215149
updateMode=update_mode,
15143-
interceptAPIRequests=intercept_api_requests,
1514415150
)
1514515151
)
1514615152

playwright/sync_api/_generated.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7330,7 +7330,7 @@ def install(
73307330
Parameters
73317331
----------
73327332
time : Union[datetime.datetime, float, str, None]
7333-
Time to initialize with, current system time by default.
7333+
Time to initialize with, current system time by default. Numeric values are Unix time in seconds.
73347334
"""
73357335

73367336
return mapping.from_maybe_impl(self._sync(self._impl_obj.install(time=time)))
@@ -7391,7 +7391,7 @@ def pause_at(self, time: typing.Union[float, str, datetime.datetime]) -> None:
73917391
Parameters
73927392
----------
73937393
time : Union[datetime.datetime, float, str]
7394-
Time to pause at.
7394+
Time to pause at. Numeric values are Unix time in seconds.
73957395
"""
73967396

73977397
return mapping.from_maybe_impl(self._sync(self._impl_obj.pause_at(time=time)))
@@ -7444,7 +7444,7 @@ def set_fixed_time(self, time: typing.Union[float, str, datetime.datetime]) -> N
74447444
Parameters
74457445
----------
74467446
time : Union[datetime.datetime, float, str]
7447-
Time to be set.
7447+
Time to be set. Numeric values are Unix time in seconds.
74487448
"""
74497449

74507450
return mapping.from_maybe_impl(
@@ -7470,7 +7470,7 @@ def set_system_time(
74707470
Parameters
74717471
----------
74727472
time : Union[datetime.datetime, float, str]
7473-
Time to be set.
7473+
Time to be set. Numeric values are Unix time in seconds.
74747474
"""
74757475

74767476
return mapping.from_maybe_impl(
@@ -10270,6 +10270,12 @@ def go_back(
1027010270

1027110271
Navigate to the previous page in history.
1027210272

10273+
**NOTE** **Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the
10274+
Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on
10275+
network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using
10276+
`page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized
10277+
`Page` state.
10278+
1027310279
Parameters
1027410280
----------
1027510281
timeout : Union[float, None]
@@ -10314,6 +10320,12 @@ def go_forward(
1031410320

1031510321
Navigate to the next page in history.
1031610322

10323+
**NOTE** **Testing Back/Forward Cache (BFCache) is not supported.** By default, Playwright disables the
10324+
Back/Forward Cache across all browsers. Even if explicitly enabled, Playwright's internal state relies on
10325+
network-level navigation events. Because BFCache restores unfreeze the DOM without firing these events, using
10326+
`page.goBack()` or `page.goForward()` to trigger a BFCache restore will result in timeouts and a desynchronized
10327+
`Page` state.
10328+
1031710329
Parameters
1031810330
----------
1031910331
timeout : Union[float, None]
@@ -15093,7 +15105,6 @@ def route_from_har(
1509315105
update: typing.Optional[bool] = None,
1509415106
update_content: typing.Optional[Literal["attach", "embed"]] = None,
1509515107
update_mode: typing.Optional[Literal["full", "minimal"]] = None,
15096-
intercept_api_requests: typing.Optional[bool] = None,
1509715108
) -> None:
1509815109
"""BrowserContext.route_from_har
1509915110

@@ -15127,10 +15138,6 @@ def route_from_har(
1512715138
When set to `minimal`, only record information necessary for routing from HAR. This omits sizes, timing, page,
1512815139
cookies, security and other types of HAR information that are not used when replaying from HAR. Defaults to
1512915140
`minimal`.
15130-
intercept_api_requests : Union[bool, None]
15131-
If set to `true`, requests made via `APIRequestContext` (such as `browser_context.request` or
15132-
`page.request`) are also served from the HAR file. By default these requests are sent to the network,
15133-
matching the behavior prior to v1.62. Defaults to `false` for backward compatibility.
1513415141
"""
1513515142

1513615143
return mapping.from_maybe_impl(
@@ -15142,7 +15149,6 @@ def route_from_har(
1514215149
update=update,
1514315150
updateContent=update_content,
1514415151
updateMode=update_mode,
15145-
interceptAPIRequests=intercept_api_requests,
1514615152
)
1514715153
)
1514815154
)

tests/async/test_har.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -806,51 +806,6 @@ async def _timeout() -> str:
806806
eval_task.cancel()
807807

808808

809-
async def test_should_fulfill_api_request_context_requests_from_har_when_intercepting(
810-
browser: Browser, server: Server, tmp_path: Path
811-
) -> None:
812-
# Ported from upstream browsercontext-har.spec.ts interceptAPIRequests.
813-
def _live(req: TestServerRequest) -> None:
814-
req.setHeader("content-type", "application/json")
815-
req.write(json.dumps({"hello": "live"}).encode())
816-
req.finish()
817-
818-
server.set_route("/api/data", _live)
819-
820-
har_path = tmp_path / "api.har"
821-
context1 = await browser.new_context()
822-
await context1.route_from_har(har_path, update=True)
823-
page1 = await context1.new_page()
824-
await page1.goto(server.EMPTY_PAGE)
825-
recorded = await page1.request.get(server.PREFIX + "/api/data")
826-
assert await recorded.json() == {"hello": "live"}
827-
await context1.close()
828-
829-
# Now stop serving from the network - the request must come from the HAR.
830-
def _not_from_har(req: TestServerRequest) -> None:
831-
req.write(b"NOT_FROM_HAR")
832-
req.finish()
833-
834-
server.set_route("/api/data", _not_from_har)
835-
context2 = await browser.new_context()
836-
await context2.route_from_har(har_path, intercept_api_requests=True)
837-
page2 = await context2.new_page()
838-
replayed = await page2.request.get(server.PREFIX + "/api/data")
839-
assert await replayed.json() == {"hello": "live"}
840-
assert replayed.timing == {
841-
"startTime": -1,
842-
"domainLookupStart": -1,
843-
"domainLookupEnd": -1,
844-
"connectStart": -1,
845-
"secureConnectionStart": -1,
846-
"connectEnd": -1,
847-
"requestStart": -1,
848-
"responseStart": -1,
849-
"responseEnd": -1,
850-
}
851-
await context2.close()
852-
853-
854809
async def test_should_not_intercept_api_request_context_requests_by_default(
855810
browser: Browser, server: Server, tmp_path: Path
856811
) -> None:

tests/async/test_worker.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ async def test_workers_should_report_network_activity_on_worker_creation(
189189

190190

191191
async def test_workers_should_format_number_using_context_locale(
192-
browser: Browser, server: Server, browser_name: str
192+
browser: Browser, server: Server
193193
) -> None:
194194
context = await browser.new_context(locale="ru-RU")
195195
page = await context.new_page()
@@ -199,9 +199,7 @@ async def test_workers_should_format_number_using_context_locale(
199199
"() => new Worker(URL.createObjectURL(new Blob(['console.log(1)'], {type: 'application/javascript'})))"
200200
)
201201
worker = await worker_info.value
202-
# https://github.com/microsoft/playwright/issues/38919
203-
expected = "10,000.2" if browser_name == "firefox" else "10\u00a0000,2"
204-
assert await worker.evaluate("() => (10000.20).toLocaleString()") == expected
202+
assert await worker.evaluate("() => (10000.20).toLocaleString()") == "10\u00a0000,2"
205203
await context.close()
206204

207205

tests/sync/test_har.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -636,51 +636,6 @@ def test_should_update_extracted_har_zip_for_page(
636636
context_2.close()
637637

638638

639-
def test_should_fulfill_api_request_context_requests_from_har_when_intercepting(
640-
browser: Browser, server: Server, tmp_path: Path
641-
) -> None:
642-
# Ported from upstream browsercontext-har.spec.ts interceptAPIRequests.
643-
def _live(req: TestServerRequest) -> None:
644-
req.setHeader("content-type", "application/json")
645-
req.write(json.dumps({"hello": "live"}).encode())
646-
req.finish()
647-
648-
server.set_route("/api/data", _live)
649-
650-
har_path = tmp_path / "api.har"
651-
context1 = browser.new_context()
652-
context1.route_from_har(har_path, update=True)
653-
page1 = context1.new_page()
654-
page1.goto(server.EMPTY_PAGE)
655-
recorded = page1.request.get(server.PREFIX + "/api/data")
656-
assert recorded.json() == {"hello": "live"}
657-
context1.close()
658-
659-
# Now stop serving from the network - the request must come from the HAR.
660-
def _not_from_har(req: TestServerRequest) -> None:
661-
req.write(b"NOT_FROM_HAR")
662-
req.finish()
663-
664-
server.set_route("/api/data", _not_from_har)
665-
context2 = browser.new_context()
666-
context2.route_from_har(har_path, intercept_api_requests=True)
667-
page2 = context2.new_page()
668-
replayed = page2.request.get(server.PREFIX + "/api/data")
669-
assert replayed.json() == {"hello": "live"}
670-
assert replayed.timing == {
671-
"startTime": -1,
672-
"domainLookupStart": -1,
673-
"domainLookupEnd": -1,
674-
"connectStart": -1,
675-
"secureConnectionStart": -1,
676-
"connectEnd": -1,
677-
"requestStart": -1,
678-
"responseStart": -1,
679-
"responseEnd": -1,
680-
}
681-
context2.close()
682-
683-
684639
def test_should_not_intercept_api_request_context_requests_by_default(
685640
browser: Browser, server: Server, tmp_path: Path
686641
) -> None:

0 commit comments

Comments
 (0)