Skip to content

Commit ba40171

Browse files
committed
Initial compiling roll to 1.53.0-alpha-2025-05-21
1 parent 0ff7fc9 commit ba40171

File tree

14 files changed

+291
-172
lines changed

14 files changed

+291
-172
lines changed

README.md

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

55
| | Linux | macOS | Windows |
66
| :--- | :---: | :---: | :---: |
7-
| Chromium <!-- GEN:chromium-version -->136.0.7103.25<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->137.0.7151.27<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->18.4<!-- GEN:stop --> ||||
99
| Firefox <!-- GEN:firefox-version -->137.0<!-- GEN:stop --> ||||
1010

playwright/_impl/_browser_type.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
HarMode,
4444
ReducedMotion,
4545
ServiceWorkersPolicy,
46+
TimeoutSettings,
4647
locals_to_params,
4748
)
4849
from playwright._impl._json_pipe import JsonPipeTransport
@@ -183,6 +184,7 @@ async def connect_over_cdp(
183184
headers: Dict[str, str] = None,
184185
) -> Browser:
185186
params = locals_to_params(locals())
187+
params["timeout"] = TimeoutSettings.launch_timeout(timeout)
186188
if params.get("headers"):
187189
params["headers"] = serialize_headers(params["headers"])
188190
response = await self._channel.send_return_as_dict("connectOverCDP", params)
@@ -205,11 +207,10 @@ async def connect(
205207
headers: Dict[str, str] = None,
206208
exposeNetwork: str = None,
207209
) -> Browser:
208-
if timeout is None:
209-
timeout = 30000
210210
if slowMo is None:
211211
slowMo = 0
212212

213+
timeout = timeout if timeout is not None else 0
213214
headers = {**(headers if headers else {}), "x-playwright-browser": self.name}
214215
local_utils = self._connection.local_utils
215216
pipe_channel = (
@@ -304,3 +305,4 @@ def normalize_launch_params(params: Dict) -> None:
304305
params["downloadsPath"] = str(Path(params["downloadsPath"]))
305306
if "tracesDir" in params:
306307
params["tracesDir"] = str(Path(params["tracesDir"]))
308+
params["timeout"] = TimeoutSettings.launch_timeout(params.get("timeout"))

playwright/_impl/_connection.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,12 @@ async def send(self, method: str, params: Dict = None) -> Any:
6464
)
6565

6666
async def send_return_as_dict(self, method: str, params: Dict = None) -> Any:
67-
return await self._connection.wrap_api_call(
68-
lambda: self._inner_send(method, params, True),
69-
self._is_internal_type,
70-
)
67+
return await self._inner_send(method, params, True)
7168

7269
def send_no_reply(self, method: str, params: Dict = None) -> None:
7370
# No reply messages are used to e.g. waitForEventInfo(after).
74-
self._connection.wrap_api_call_sync(
75-
lambda: self._connection._send_message_to_server(
76-
self._object, method, {} if params is None else params, True
77-
)
71+
self._connection._send_message_to_server(
72+
self._object, method, {} if params is None else params, True
7873
)
7974

8075
async def _inner_send(

playwright/_impl/_element_handle.py

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def __init__(
5555
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
5656
) -> None:
5757
super().__init__(parent, type, guid, initializer)
58+
self._frame = cast("Frame", parent)
5859

5960
async def _createSelectorForTest(self, name: str) -> Optional[str]:
6061
return await self._channel.send("createSelectorForTest", dict(name=name))
@@ -104,7 +105,9 @@ async def dispatch_event(self, type: str, eventInit: Dict = None) -> None:
104105
)
105106

106107
async def scroll_into_view_if_needed(self, timeout: float = None) -> None:
107-
await self._channel.send("scrollIntoViewIfNeeded", locals_to_params(locals()))
108+
await self._channel.send(
109+
"scrollIntoViewIfNeeded", self._locals_to_params_with_timeout(locals())
110+
)
108111

109112
async def hover(
110113
self,
@@ -115,7 +118,7 @@ async def hover(
115118
force: bool = None,
116119
trial: bool = None,
117120
) -> None:
118-
await self._channel.send("hover", locals_to_params(locals()))
121+
await self._channel.send("hover", self._locals_to_params_with_timeout(locals()))
119122

120123
async def click(
121124
self,
@@ -129,7 +132,7 @@ async def click(
129132
noWaitAfter: bool = None,
130133
trial: bool = None,
131134
) -> None:
132-
await self._channel.send("click", locals_to_params(locals()))
135+
await self._channel.send("click", self._locals_to_params_with_timeout(locals()))
133136

134137
async def dblclick(
135138
self,
@@ -142,7 +145,9 @@ async def dblclick(
142145
noWaitAfter: bool = None,
143146
trial: bool = None,
144147
) -> None:
145-
await self._channel.send("dblclick", locals_to_params(locals()))
148+
await self._channel.send(
149+
"dblclick", self._locals_to_params_with_timeout(locals())
150+
)
146151

147152
async def select_option(
148153
self,
@@ -154,7 +159,7 @@ async def select_option(
154159
force: bool = None,
155160
noWaitAfter: bool = None,
156161
) -> List[str]:
157-
params = locals_to_params(
162+
params = self._locals_to_params_with_timeout(
158163
dict(
159164
timeout=timeout,
160165
force=force,
@@ -172,7 +177,7 @@ async def tap(
172177
noWaitAfter: bool = None,
173178
trial: bool = None,
174179
) -> None:
175-
await self._channel.send("tap", locals_to_params(locals()))
180+
await self._channel.send("tap", self._locals_to_params_with_timeout(locals()))
176181

177182
async def fill(
178183
self,
@@ -181,13 +186,17 @@ async def fill(
181186
noWaitAfter: bool = None,
182187
force: bool = None,
183188
) -> None:
184-
await self._channel.send("fill", locals_to_params(locals()))
189+
await self._channel.send("fill", self._locals_to_params_with_timeout(locals()))
185190

186191
async def select_text(self, force: bool = None, timeout: float = None) -> None:
187-
await self._channel.send("selectText", locals_to_params(locals()))
192+
await self._channel.send(
193+
"selectText", self._locals_to_params_with_timeout(locals())
194+
)
188195

189196
async def input_value(self, timeout: float = None) -> str:
190-
return await self._channel.send("inputValue", locals_to_params(locals()))
197+
return await self._channel.send(
198+
"inputValue", self._locals_to_params_with_timeout(locals())
199+
)
191200

192201
async def set_input_files(
193202
self,
@@ -219,7 +228,7 @@ async def type(
219228
timeout: float = None,
220229
noWaitAfter: bool = None,
221230
) -> None:
222-
await self._channel.send("type", locals_to_params(locals()))
231+
await self._channel.send("type", self._locals_to_params_with_timeout(locals()))
223232

224233
async def press(
225234
self,
@@ -228,7 +237,7 @@ async def press(
228237
timeout: float = None,
229238
noWaitAfter: bool = None,
230239
) -> None:
231-
await self._channel.send("press", locals_to_params(locals()))
240+
await self._channel.send("press", self._locals_to_params_with_timeout(locals()))
232241

233242
async def set_checked(
234243
self,
@@ -262,7 +271,7 @@ async def check(
262271
noWaitAfter: bool = None,
263272
trial: bool = None,
264273
) -> None:
265-
await self._channel.send("check", locals_to_params(locals()))
274+
await self._channel.send("check", self._locals_to_params_with_timeout(locals()))
266275

267276
async def uncheck(
268277
self,
@@ -272,7 +281,9 @@ async def uncheck(
272281
noWaitAfter: bool = None,
273282
trial: bool = None,
274283
) -> None:
275-
await self._channel.send("uncheck", locals_to_params(locals()))
284+
await self._channel.send(
285+
"uncheck", self._locals_to_params_with_timeout(locals())
286+
)
276287

277288
async def bounding_box(self) -> Optional[FloatRect]:
278289
return await self._channel.send("boundingBox")
@@ -291,7 +302,7 @@ async def screenshot(
291302
maskColor: str = None,
292303
style: str = None,
293304
) -> bytes:
294-
params = locals_to_params(locals())
305+
params = self._locals_to_params_with_timeout(locals())
295306
if "path" in params:
296307
del params["path"]
297308
if "mask" in params:
@@ -367,7 +378,9 @@ async def wait_for_element_state(
367378
],
368379
timeout: float = None,
369380
) -> None:
370-
await self._channel.send("waitForElementState", locals_to_params(locals()))
381+
await self._channel.send(
382+
"waitForElementState", self._locals_to_params_with_timeout(locals())
383+
)
371384

372385
async def wait_for_selector(
373386
self,
@@ -377,9 +390,16 @@ async def wait_for_selector(
377390
strict: bool = None,
378391
) -> Optional["ElementHandle"]:
379392
return from_nullable_channel(
380-
await self._channel.send("waitForSelector", locals_to_params(locals()))
393+
await self._channel.send(
394+
"waitForSelector", self._locals_to_params_with_timeout(locals())
395+
)
381396
)
382397

398+
def _locals_to_params_with_timeout(self, args: Dict) -> Dict:
399+
params = locals_to_params(args)
400+
params["timeout"] = self._frame._timeout(params.get("timeout"))
401+
return params
402+
383403

384404
def convert_select_option_values(
385405
value: Union[str, Sequence[str]] = None,

playwright/_impl/_fetch.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
Error,
3737
NameValue,
3838
TargetClosedError,
39+
TimeoutSettings,
3940
async_readfile,
4041
async_writefile,
4142
is_file_payload,
@@ -92,6 +93,7 @@ async def new_context(
9293
APIRequestContext,
9394
from_channel(await self.playwright._channel.send("newRequest", params)),
9495
)
96+
context._timeout_settings.set_default_timeout(timeout)
9597
return context
9698

9799

@@ -102,6 +104,7 @@ def __init__(
102104
super().__init__(parent, type, guid, initializer)
103105
self._tracing: Tracing = from_channel(initializer["tracing"])
104106
self._close_reason: Optional[str] = None
107+
self._timeout_settings = TimeoutSettings(None)
105108

106109
async def dispose(self, reason: str = None) -> None:
107110
self._close_reason = reason
@@ -414,7 +417,7 @@ async def _inner_fetch(
414417
"jsonData": json_data,
415418
"formData": form_data,
416419
"multipartData": multipart_data,
417-
"timeout": timeout,
420+
"timeout": self._timeout_settings.timeout(timeout),
418421
"failOnStatusCode": failOnStatusCode,
419422
"ignoreHTTPSErrors": ignoreHTTPSErrors,
420423
"maxRedirects": maxRedirects,

0 commit comments

Comments
 (0)