Skip to content

Commit 2886f00

Browse files
authored
chore: roll Playwright to 1.39.0-alpha-oct-10-2023 (microsoft#2109)
1 parent e81afd4 commit 2886f00

14 files changed

+263
-165
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# 🎭 [Playwright](https://playwright.dev) for Python [![PyPI version](https://badge.fury.io/py/playwright.svg)](https://pypi.python.org/pypi/playwright/) [![Anaconda version](https://img.shields.io/conda/v/microsoft/playwright)](https://anaconda.org/Microsoft/playwright) [![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://aka.ms/playwright-slack)
1+
# 🎭 [Playwright](https://playwright.dev) for Python [![PyPI version](https://badge.fury.io/py/playwright.svg)](https://pypi.python.org/pypi/playwright/) [![Anaconda version](https://img.shields.io/conda/v/microsoft/playwright)](https://anaconda.org/Microsoft/playwright) [![Join Discord](https://img.shields.io/badge/join-discord-infomational)](https://aka.ms/playwright/discord)
22

33
Playwright is a Python library to automate [Chromium](https://www.chromium.org/Home), [Firefox](https://www.mozilla.org/en-US/firefox/new/) and [WebKit](https://webkit.org/) browsers with a single API. Playwright delivers automation that is **ever-green**, **capable**, **reliable** and **fast**. [See how Playwright is better](https://playwright.dev/python/docs/why-playwright).
44

55
| | Linux | macOS | Windows |
66
| :--- | :---: | :---: | :---: |
7-
| Chromium <!-- GEN:chromium-version -->117.0.5938.62<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->119.0.6045.9<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->17.0<!-- GEN:stop --> ||||
9-
| Firefox <!-- GEN:firefox-version -->117.0<!-- GEN:stop --> ||||
9+
| Firefox <!-- GEN:firefox-version -->118.0.1<!-- GEN:stop --> ||||
1010

1111
## Documentation
1212

@@ -49,6 +49,6 @@ asyncio.run(main())
4949
## Other languages
5050

5151
More comfortable in another programming language? [Playwright](https://playwright.dev) is also available in
52-
- [Node.js (JavaScript / TypeScript)](https://playwright.dev/docs/intro)
53-
- [.NET](https://playwright.dev/dotnet/docs/intro)
54-
- [Java](https://playwright.dev/java/docs/intro)
52+
- [Node.js (JavaScript / TypeScript)](https://playwright.dev/docs/intro),
53+
- [.NET](https://playwright.dev/dotnet/docs/intro),
54+
- [Java](https://playwright.dev/java/docs/intro).

playwright/_impl/_assertions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ async def to_have_attribute(
220220
__tracebackhide__ = True
221221
expected_text = to_expected_text_values([value])
222222
await self._expect_impl(
223-
"to.have.attribute",
223+
"to.have.attribute.value",
224224
FrameExpectOptions(
225225
expressionArg=name, expectedText=expected_text, timeout=timeout
226226
),

playwright/_impl/_browser_context.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def __init__(
145145
)
146146
self._channel.on(
147147
"console",
148-
lambda params: self._on_console_message(from_channel(params["message"])),
148+
lambda event: self._on_console_message(event),
149149
)
150150

151151
self._channel.on(
@@ -545,7 +545,8 @@ def _on_request_finished(
545545
if response:
546546
response._finished_future.set_result(True)
547547

548-
def _on_console_message(self, message: ConsoleMessage) -> None:
548+
def _on_console_message(self, event: Dict) -> None:
549+
message = ConsoleMessage(event, self._loop, self._dispatcher_fiber)
549550
self.emit(BrowserContext.Events.Console, message)
550551
page = message.page
551552
if page:

playwright/_impl/_connection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,12 @@ def _send_message_to_server(
345345
"internal": not stack_trace_information["apiName"],
346346
},
347347
}
348-
self._transport.send(message)
349-
self._callbacks[id] = callback
350-
351348
if self._tracing_count > 0 and frames and guid != "localUtils":
352349
self.local_utils.add_stack_to_tracing_no_reply(id, frames)
353350

351+
self._transport.send(message)
352+
self._callbacks[id] = callback
353+
354354
return callback
355355

356356
def dispatch(self, msg: ParsedMessagePayload) -> None:

playwright/_impl/_console_message.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,25 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import TYPE_CHECKING, Dict, List, Optional
15+
from asyncio import AbstractEventLoop
16+
from typing import TYPE_CHECKING, Any, Dict, List, Optional
1617

1718
from playwright._impl._api_structures import SourceLocation
18-
from playwright._impl._connection import (
19-
ChannelOwner,
20-
from_channel,
21-
from_nullable_channel,
22-
)
19+
from playwright._impl._connection import from_channel, from_nullable_channel
2320
from playwright._impl._js_handle import JSHandle
2421

2522
if TYPE_CHECKING: # pragma: no cover
2623
from playwright._impl._page import Page
2724

2825

29-
class ConsoleMessage(ChannelOwner):
26+
class ConsoleMessage:
3027
def __init__(
31-
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
28+
self, event: Dict, loop: AbstractEventLoop, dispatcher_fiber: Any
3229
) -> None:
33-
super().__init__(parent, type, guid, initializer)
34-
# Note: currently, we only report console messages for pages and they always have a page.
35-
# However, in the future we might report console messages for service workers or something else,
36-
# where page() would be null.
37-
self._page: Optional["Page"] = from_nullable_channel(initializer.get("page"))
30+
self._event = event
31+
self._loop = loop
32+
self._dispatcher_fiber = dispatcher_fiber
33+
self._page: Optional["Page"] = from_nullable_channel(event.get("page"))
3834

3935
def __repr__(self) -> str:
4036
return f"<ConsoleMessage type={self.type} text={self.text}>"
@@ -44,19 +40,19 @@ def __str__(self) -> str:
4440

4541
@property
4642
def type(self) -> str:
47-
return self._initializer["type"]
43+
return self._event["type"]
4844

4945
@property
5046
def text(self) -> str:
51-
return self._initializer["text"]
47+
return self._event["text"]
5248

5349
@property
5450
def args(self) -> List[JSHandle]:
55-
return list(map(from_channel, self._initializer["args"]))
51+
return list(map(from_channel, self._event["args"]))
5652

5753
@property
5854
def location(self) -> SourceLocation:
59-
return self._initializer["location"]
55+
return self._event["location"]
6056

6157
@property
6258
def page(self) -> Optional["Page"]:

playwright/_impl/_js_handle.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,6 @@ def parse_value(value: Any, refs: Optional[Dict[int, Any]] = None) -> Any:
195195
if "bi" in value:
196196
return int(value["bi"])
197197

198-
if "m" in value:
199-
v = {}
200-
refs[value["m"]["id"]] = v
201-
return v
202-
203-
if "se" in value:
204-
v = set()
205-
refs[value["se"]["id"]] = v
206-
return v
207-
208198
if "a" in value:
209199
a: List = []
210200
refs[value["id"]] = a

playwright/_impl/_local_utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def __init__(
2525
self, parent: ChannelOwner, type: str, guid: str, initializer: Dict
2626
) -> None:
2727
super().__init__(parent, type, guid, initializer)
28+
self.devices = {
29+
device["name"]: parse_device_descriptor(device["descriptor"])
30+
for device in initializer["deviceDescriptors"]
31+
}
2832

2933
async def zip(self, params: Dict) -> None:
3034
await self._channel.send("zip", params)
@@ -75,3 +79,14 @@ def add_stack_to_tracing_no_reply(self, id: int, frames: List[StackFrame]) -> No
7579
}
7680
},
7781
)
82+
83+
84+
def parse_device_descriptor(dict: Dict) -> Dict:
85+
return {
86+
"user_agent": dict["userAgent"],
87+
"viewport": dict["viewport"],
88+
"device_scale_factor": dict["deviceScaleFactor"],
89+
"is_mobile": dict["isMobile"],
90+
"has_touch": dict["hasTouch"],
91+
"default_browser_type": dict["defaultBrowserType"],
92+
}

playwright/_impl/_object_factory.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from playwright._impl._browser_type import BrowserType
2121
from playwright._impl._cdp_session import CDPSession
2222
from playwright._impl._connection import ChannelOwner
23-
from playwright._impl._console_message import ConsoleMessage
2423
from playwright._impl._dialog import Dialog
2524
from playwright._impl._element_handle import ElementHandle
2625
from playwright._impl._fetch import APIRequestContext
@@ -60,8 +59,6 @@ def create_remote_object(
6059
return BrowserContext(parent, type, guid, initializer)
6160
if type == "CDPSession":
6261
return CDPSession(parent, type, guid, initializer)
63-
if type == "ConsoleMessage":
64-
return ConsoleMessage(parent, type, guid, initializer)
6562
if type == "Dialog":
6663
return Dialog(parent, type, guid, initializer)
6764
if type == "ElementHandle":

playwright/_impl/_playwright.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from playwright._impl._browser_type import BrowserType
1818
from playwright._impl._connection import ChannelOwner, from_channel
1919
from playwright._impl._fetch import APIRequest
20-
from playwright._impl._local_utils import LocalUtils
2120
from playwright._impl._selectors import Selectors, SelectorsOwner
2221

2322

@@ -48,12 +47,7 @@ def __init__(
4847
self._connection.on(
4948
"close", lambda: self.selectors._remove_channel(selectors_owner)
5049
)
51-
self.devices = {}
52-
self.devices = {
53-
device["name"]: parse_device_descriptor(device["descriptor"])
54-
for device in initializer["deviceDescriptors"]
55-
}
56-
self._utils: LocalUtils = from_channel(initializer["utils"])
50+
self.devices = self._connection.local_utils.devices
5751

5852
def __getitem__(self, value: str) -> "BrowserType":
5953
if value == "chromium":
@@ -72,14 +66,3 @@ def _set_selectors(self, selectors: Selectors) -> None:
7266

7367
async def stop(self) -> None:
7468
pass
75-
76-
77-
def parse_device_descriptor(dict: Dict) -> Dict:
78-
return {
79-
"user_agent": dict["userAgent"],
80-
"viewport": dict["viewport"],
81-
"device_scale_factor": dict["deviceScaleFactor"],
82-
"is_mobile": dict["isMobile"],
83-
"has_touch": dict["hasTouch"],
84-
"default_browser_type": dict["defaultBrowserType"],
85-
}

0 commit comments

Comments
 (0)