Skip to content

Commit b7eb7d8

Browse files
chore: roll to Playwright 1.16.0-next-1632960932000 (microsoft#925)
1 parent a385b00 commit b7eb7d8

File tree

12 files changed

+118
-21
lines changed

12 files changed

+118
-21
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 -->96.0.4652.0<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->96.0.4655.0<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->15.0<!-- GEN:stop --> ||||
99
| Firefox <!-- GEN:firefox-version -->92.0<!-- GEN:stop --> ||||
1010

playwright/_impl/_async_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ async def __aenter__(self: Self) -> Self:
9393
return self
9494

9595
async def __aexit__(
96-
self: Self,
96+
self,
9797
exc_type: Type[BaseException],
9898
exc_val: BaseException,
9999
traceback: TracebackType,
100100
) -> None:
101101
await self.close()
102102

103-
async def close(self: Self) -> None:
103+
async def close(self) -> None:
104104
...

playwright/_impl/_helper.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ErrorPayload(TypedDict, total=False):
6767
message: str
6868
name: str
6969
stack: str
70-
value: Any
70+
value: Optional[Any]
7171

7272

7373
class ContinueParameters(TypedDict, total=False):
@@ -159,7 +159,9 @@ def navigation_timeout(self) -> float:
159159

160160

161161
def serialize_error(ex: Exception, tb: Optional[TracebackType]) -> ErrorPayload:
162-
return dict(message=str(ex), name="Error", stack="".join(traceback.format_tb(tb)))
162+
return ErrorPayload(
163+
message=str(ex), name="Error", stack="".join(traceback.format_tb(tb))
164+
)
163165

164166

165167
def parse_error(error: ErrorPayload) -> Error:

playwright/_impl/_locator.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
Optional,
2525
TypeVar,
2626
Union,
27-
cast,
2827
)
2928

3029
from playwright._impl._api_structures import FilePayload, FloatRect, Position
@@ -173,12 +172,11 @@ async def element_handle(
173172
timeout: float = None,
174173
) -> ElementHandle:
175174
params = locals_to_params(locals())
176-
return cast(
177-
ElementHandle,
178-
await self._frame.wait_for_selector(
179-
self._selector, strict=True, state="attached", **params
180-
),
175+
handle = await self._frame.wait_for_selector(
176+
self._selector, strict=True, state="attached", **params
181177
)
178+
assert handle
179+
return handle
182180

183181
async def element_handles(self) -> List[ElementHandle]:
184182
return await self._frame.query_selector_all(self._selector)
@@ -201,7 +199,7 @@ async def focus(self, timeout: float = None) -> None:
201199
async def count(
202200
self,
203201
) -> int:
204-
return cast(int, await self.evaluate_all("ee => ee.length"))
202+
return int(await self.evaluate_all("ee => ee.length"))
205203

206204
async def get_attribute(self, name: str, timeout: float = None) -> Optional[str]:
207205
params = locals_to_params(locals())
@@ -439,6 +437,15 @@ async def all_text_contents(
439437
self._selector, "ee => ee.map(e => e.textContent || '')"
440438
)
441439

440+
async def wait_for(
441+
self,
442+
timeout: float = None,
443+
state: Literal["attached", "detached", "hidden", "visible"] = None,
444+
) -> None:
445+
await self._frame.wait_for_selector(
446+
self._selector, strict=True, timeout=timeout, state=state
447+
)
448+
442449
async def set_checked(
443450
self,
444451
checked: bool,

playwright/_impl/_sync_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ def __enter__(self: Self) -> Self:
167167
return self
168168

169169
def __exit__(
170-
self: Self,
170+
self,
171171
exc_type: Type[BaseException],
172172
exc_val: BaseException,
173173
traceback: TracebackType,
174174
) -> None:
175175
self.close()
176176

177-
def close(self: Self) -> None:
177+
def close(self) -> None:
178178
...

playwright/_impl/_transport.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from typing import Callable, Dict, Optional, Union
2424

2525
import websockets
26+
import websockets.exceptions
2627
from pyee import AsyncIOEventEmitter
2728
from websockets.client import connect as websocket_connect
2829

playwright/async_api/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ def async_playwright() -> PlaywrightContextManager:
7676
__all__ = [
7777
"async_playwright",
7878
"Accessibility",
79-
"BindingCall",
8079
"Browser",
8180
"BrowserContext",
8281
"BrowserType",
@@ -110,7 +109,6 @@ def async_playwright() -> PlaywrightContextManager:
110109
"Selectors",
111110
"SourceLocation",
112111
"StorageState",
113-
"sync_playwright",
114112
"TimeoutError",
115113
"Touchscreen",
116114
"Video",

playwright/async_api/_generated.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11497,7 +11497,8 @@ async def launch_persistent_context(
1149711497
Path to a User Data Directory, which stores browser session data like cookies and local storage. More details for
1149811498
[Chromium](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md#introduction) and
1149911499
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options#User_Profile). Note that Chromium's user
11500-
data directory is the **parent** directory of the "Profile Path" seen at `chrome://version`.
11500+
data directory is the **parent** directory of the "Profile Path" seen at `chrome://version`. Pass an empty string to use
11501+
a temporary directory instead.
1150111502
channel : Union[str, NoneType]
1150211503
Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
1150311504
"msedge-beta", "msedge-dev", "msedge-canary". Read more about using
@@ -13345,6 +13346,46 @@ async def all_text_contents(self) -> typing.List[str]:
1334513346
)
1334613347
)
1334713348

13349+
async def wait_for(
13350+
self,
13351+
*,
13352+
timeout: float = None,
13353+
state: Literal["attached", "detached", "hidden", "visible"] = None
13354+
) -> NoneType:
13355+
"""Locator.wait_for
13356+
13357+
Returns when element specified by locator satisfies the `state` option.
13358+
13359+
If target element already satisfies the condition, the method returns immediately. Otherwise, waits for up to `timeout`
13360+
milliseconds until the condition is met.
13361+
13362+
```py
13363+
order_sent = page.locator(\"#order-sent\")
13364+
await order_sent.wait_for()
13365+
```
13366+
13367+
Parameters
13368+
----------
13369+
timeout : Union[float, NoneType]
13370+
Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
13371+
using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods.
13372+
state : Union["attached", "detached", "hidden", "visible", NoneType]
13373+
Defaults to `'visible'`. Can be either:
13374+
- `'attached'` - wait for element to be present in DOM.
13375+
- `'detached'` - wait for element to not be present in DOM.
13376+
- `'visible'` - wait for element to have non-empty bounding box and no `visibility:hidden`. Note that element without
13377+
any content or with `display:none` has an empty bounding box and is not considered visible.
13378+
- `'hidden'` - wait for element to be either detached from DOM, or have an empty bounding box or `visibility:hidden`.
13379+
This is opposite to the `'visible'` option.
13380+
"""
13381+
13382+
return mapping.from_maybe_impl(
13383+
await self._async(
13384+
"locator.wait_for",
13385+
self._impl_obj.wait_for(timeout=timeout, state=state),
13386+
)
13387+
)
13388+
1334813389
async def set_checked(
1334913390
self,
1335013391
checked: bool,

playwright/sync_api/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ def sync_playwright() -> PlaywrightContextManager:
7474

7575

7676
__all__ = [
77-
"async_playwright",
7877
"Accessibility",
79-
"BindingCall",
8078
"Browser",
8179
"BrowserContext",
8280
"BrowserType",

playwright/sync_api/_generated.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11244,7 +11244,8 @@ def launch_persistent_context(
1124411244
Path to a User Data Directory, which stores browser session data like cookies and local storage. More details for
1124511245
[Chromium](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md#introduction) and
1124611246
[Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options#User_Profile). Note that Chromium's user
11247-
data directory is the **parent** directory of the "Profile Path" seen at `chrome://version`.
11247+
data directory is the **parent** directory of the "Profile Path" seen at `chrome://version`. Pass an empty string to use
11248+
a temporary directory instead.
1124811249
channel : Union[str, NoneType]
1124911250
Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge",
1125011251
"msedge-beta", "msedge-dev", "msedge-canary". Read more about using
@@ -13074,6 +13075,46 @@ def all_text_contents(self) -> typing.List[str]:
1307413075
self._sync("locator.all_text_contents", self._impl_obj.all_text_contents())
1307513076
)
1307613077

13078+
def wait_for(
13079+
self,
13080+
*,
13081+
timeout: float = None,
13082+
state: Literal["attached", "detached", "hidden", "visible"] = None
13083+
) -> NoneType:
13084+
"""Locator.wait_for
13085+
13086+
Returns when element specified by locator satisfies the `state` option.
13087+
13088+
If target element already satisfies the condition, the method returns immediately. Otherwise, waits for up to `timeout`
13089+
milliseconds until the condition is met.
13090+
13091+
```py
13092+
order_sent = page.locator(\"#order-sent\")
13093+
order_sent.wait_for()
13094+
```
13095+
13096+
Parameters
13097+
----------
13098+
timeout : Union[float, NoneType]
13099+
Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
13100+
using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods.
13101+
state : Union["attached", "detached", "hidden", "visible", NoneType]
13102+
Defaults to `'visible'`. Can be either:
13103+
- `'attached'` - wait for element to be present in DOM.
13104+
- `'detached'` - wait for element to not be present in DOM.
13105+
- `'visible'` - wait for element to have non-empty bounding box and no `visibility:hidden`. Note that element without
13106+
any content or with `display:none` has an empty bounding box and is not considered visible.
13107+
- `'hidden'` - wait for element to be either detached from DOM, or have an empty bounding box or `visibility:hidden`.
13108+
This is opposite to the `'visible'` option.
13109+
"""
13110+
13111+
return mapping.from_maybe_impl(
13112+
self._sync(
13113+
"locator.wait_for",
13114+
self._impl_obj.wait_for(timeout=timeout, state=state),
13115+
)
13116+
)
13117+
1307713118
def set_checked(
1307813119
self,
1307913120
checked: bool,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
InWheel = None
2929
from wheel.bdist_wheel import bdist_wheel as BDistWheelCommand
3030

31-
driver_version = "1.16.0-next-1632717011000"
31+
driver_version = "1.16.0-next-1632960932000"
3232

3333

3434
def extractall(zip: zipfile.ZipFile, path: str) -> None:

tests/async/test_locators.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,3 +465,12 @@ async def test_locators_set_checked(page: Page):
465465
assert await page.evaluate("checkbox.checked")
466466
await locator.set_checked(False)
467467
assert await page.evaluate("checkbox.checked") is False
468+
469+
470+
async def test_locators_wait_for(page: Page) -> None:
471+
await page.set_content("<div></div>")
472+
locator = page.locator("div")
473+
task = locator.wait_for()
474+
await page.eval_on_selector("div", "div => div.innerHTML = '<span>target</span>'")
475+
await task
476+
assert await locator.text_content() == "target"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy