Skip to content

Commit af97862

Browse files
dgozmanmxschmitt
andauthored
feat: roll driver to 1.3.0-next.1596843106133, handle paths on the client side (#163)
Co-authored-by: Max Schmitt <[email protected]>
1 parent 9364c37 commit af97862

15 files changed

+116
-96
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 🎭 [Playwright](https://github.com/microsoft/playwright) for Python
22

3-
[![PyPI version](https://badge.fury.io/py/playwright.svg)](https://pypi.python.org/pypi/playwright/) [![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://join.slack.com/t/playwright/shared_invite/enQtOTEyMTUxMzgxMjIwLThjMDUxZmIyNTRiMTJjNjIyMzdmZDA3MTQxZWUwZTFjZjQwNGYxZGM5MzRmNzZlMWI5ZWUyOTkzMjE5Njg1NDg) <!-- GEN:chromium-version-badge -->[![Chromium version](https://img.shields.io/badge/chromium-86.0.4217.0-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-78.0b5-blue.svg?logo=mozilla-firefox)](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> [![WebKit version](https://img.shields.io/badge/webkit-14.0-blue.svg?logo=safari)](https://webkit.org/)
3+
[![PyPI version](https://badge.fury.io/py/playwright.svg)](https://pypi.python.org/pypi/playwright/) [![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://join.slack.com/t/playwright/shared_invite/enQtOTEyMTUxMzgxMjIwLThjMDUxZmIyNTRiMTJjNjIyMzdmZDA3MTQxZWUwZTFjZjQwNGYxZGM5MzRmNzZlMWI5ZWUyOTkzMjE5Njg1NDg) <!-- GEN:chromium-version-badge -->[![Chromium version](https://img.shields.io/badge/chromium-86.0.4217.0-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-79.0a1-blue.svg?logo=mozilla-firefox)](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> [![WebKit version](https://img.shields.io/badge/webkit-14.0-blue.svg?logo=safari)](https://webkit.org/)
44

55
##### [Docs](#documentation) | [API reference](https://github.com/microsoft/playwright/blob/master/docs/api.md)
66

@@ -10,7 +10,7 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
1010
| :--- | :---: | :---: | :---: |
1111
| Chromium <!-- GEN:chromium-version -->86.0.4217.0<!-- GEN:stop --> ||||
1212
| WebKit 14.0 ||||
13-
| Firefox <!-- GEN:firefox-version -->78.0b5<!-- GEN:stop --> ||||
13+
| Firefox <!-- GEN:firefox-version -->79.0a1<!-- GEN:stop --> ||||
1414

1515
Headless execution is supported for all the browsers on all platforms.
1616

api.json

Lines changed: 40 additions & 40 deletions
Large diffs are not rendered by default.

driver/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"license": "Apache-2.0",
1515
"dependencies": {
16-
"playwright": "1.3.0-next.1596659749397"
16+
"playwright": "1.3.0-next.1596843106133"
1717
},
1818
"devDependencies": {
1919
"pkg": "^4.4.9"

playwright/async_api.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ async def hover(
944944
) -> NoneType:
945945
"""ElementHandle.hover
946946
947-
This method scrolls element into view if needed, and then uses page.mouse to hover over the center of the element.
947+
This method waits for actionability checks, then scrolls the element into view if needed and uses page.mouse to hover over the center of the element.
948948
If the element is detached from DOM, the method throws an error.
949949
950950
Parameters
@@ -979,7 +979,7 @@ async def click(
979979
) -> NoneType:
980980
"""ElementHandle.click
981981
982-
This method scrolls element into view if needed, and then uses page.mouse to click in the center of the element.
982+
This method waits for actionability checks, then scrolls the element into view if needed and uses page.mouse to click in the center of the element.
983983
If the element is detached from DOM, the method throws an error.
984984
985985
Parameters
@@ -1028,7 +1028,7 @@ async def dblclick(
10281028
) -> NoneType:
10291029
"""ElementHandle.dblclick
10301030
1031-
This method scrolls element into view if needed, and then uses page.mouse to click in the center of the element.
1031+
This method waits for actionability checks, then scrolls the element into view if needed and uses page.mouse to double click in the center of the element.
10321032
If the element is detached from DOM, the method throws an error.
10331033
Bear in mind that if the first click of the `dblclick()` triggers a navigation event, there will be an exception.
10341034
@@ -1241,7 +1241,7 @@ async def check(
12411241
) -> NoneType:
12421242
"""ElementHandle.check
12431243
1244-
If element is not already checked, it scrolls it into view if needed, and then uses elementHandle.click to click in the center of the element.
1244+
This method waits for actionability checks. Then, if the element is not already checked, this method scrolls the element into view and uses elementHandle.click to click in the center of the element.
12451245
12461246
Parameters
12471247
----------
@@ -1263,7 +1263,7 @@ async def uncheck(
12631263
) -> NoneType:
12641264
"""ElementHandle.uncheck
12651265
1266-
If element is not already unchecked, it scrolls it into view if needed, and then uses elementHandle.click to click in the center of the element.
1266+
This method waits for actionability checks. Then, if the element is not already unchecked, this method scrolls the element into view and uses elementHandle.click to click in the center of the element.
12671267
12681268
Parameters
12691269
----------
@@ -2108,7 +2108,7 @@ async def click(
21082108
) -> NoneType:
21092109
"""Frame.click
21102110
2111-
This method fetches an element with `selector`, scrolls it into view if needed, and then uses page.mouse to click in the center of the element.
2111+
This method waits for an element matching `selector`, waits for actionability checks, then scrolls the element into view if needed and uses page.mouse to click in the center of the element.
21122112
If there's no element matching `selector`, the method waits until a matching element appears in the DOM. If the element is detached during the actionability checks, the action is retried.
21132113
21142114
Parameters
@@ -2160,7 +2160,7 @@ async def dblclick(
21602160
) -> NoneType:
21612161
"""Frame.dblclick
21622162
2163-
This method fetches an element with `selector`, scrolls it into view if needed, and then uses page.mouse to double click in the center of the element.
2163+
This method waits for an element matching `selector`, waits for actionability checks, then scrolls the element into view if needed and uses page.mouse to double click in the center of the element.
21642164
If there's no element matching `selector`, the method waits until a matching element appears in the DOM. If the element is detached during the actionability checks, the action is retried.
21652165
Bear in mind that if the first click of the `dblclick()` triggers a navigation event, there will be an exception.
21662166
@@ -2339,7 +2339,7 @@ async def hover(
23392339
) -> NoneType:
23402340
"""Frame.hover
23412341
2342-
This method fetches an element with `selector`, scrolls it into view if needed, and then uses page.mouse to hover over the center of the element.
2342+
This method waits for an element matching `selector`, waits for actionability checks, then scrolls the element into view if needed and uses page.mouse to hover over the center of the element.
23432343
If there's no element matching `selector`, the method waits until a matching element appears in the DOM. If the element is detached during the actionability checks, the action is retried.
23442344
23452345
Parameters
@@ -2529,7 +2529,7 @@ async def check(
25292529
) -> NoneType:
25302530
"""Frame.check
25312531
2532-
This method fetches an element with `selector`, if element is not already checked, it scrolls it into view if needed, and then uses frame.click to click in the center of the element.
2532+
This method waits for an element matching `selector`, waits for actionability checks. Then, if the element is not already checked, this method scrolls the element into view and uses elementHandle.click to click in the center of the element.
25332533
If there's no element matching `selector`, the method waits until a matching element appears in the DOM. If the element is detached during the actionability checks, the action is retried.
25342534
25352535
Parameters
@@ -2558,7 +2558,7 @@ async def uncheck(
25582558
) -> NoneType:
25592559
"""Frame.uncheck
25602560
2561-
This method fetches an element with `selector`, if element is not already unchecked, it scrolls it into view if needed, and then uses frame.click to click in the center of the element.
2561+
This method waits for an element matching `selector`, waits for actionability checks. Then, if the element is not already unchecked, this method scrolls the element into view and uses elementHandle.click to click in the center of the element.
25622562
If there's no element matching `selector`, the method waits until a matching element appears in the DOM. If the element is detached during the actionability checks, the action is retried.
25632563
25642564
Parameters
@@ -4068,7 +4068,7 @@ async def click(
40684068
) -> NoneType:
40694069
"""Page.click
40704070
4071-
This method fetches an element with `selector`, scrolls it into view if needed, and then uses page.mouse to click in the center of the element.
4071+
This method waits for an element matching `selector`, waits for actionability checks, then scrolls the element into view if needed and uses page.mouse to click in the center of the element.
40724072
If there's no element matching `selector`, the method waits until a matching element appears in the DOM. If the element is detached during the actionability checks, the action is retried.
40734073
Shortcut for page.mainFrame().click(selector[, options]).
40744074
@@ -4121,7 +4121,7 @@ async def dblclick(
41214121
) -> NoneType:
41224122
"""Page.dblclick
41234123
4124-
This method fetches an element with `selector`, scrolls it into view if needed, and then uses page.mouse to double click in the center of the element.
4124+
This method waits for an element matching `selector`, waits for actionability checks, then scrolls the element into view if needed and uses page.mouse to double click in the center of the element.
41254125
If there's no element matching `selector`, the method waits until a matching element appears in the DOM. If the element is detached during the actionability checks, the action is retried.
41264126
Bear in mind that if the first click of the `dblclick()` triggers a navigation event, there will be an exception.
41274127
@@ -4304,7 +4304,7 @@ async def hover(
43044304
) -> NoneType:
43054305
"""Page.hover
43064306
4307-
This method fetches an element with `selector`, scrolls it into view if needed, and then uses page.mouse to hover over the center of the element.
4307+
This method waits for an element matching `selector`, waits for actionability checks, then scrolls the element into view if needed and uses page.mouse to hover over the center of the element.
43084308
If there's no element matching `selector`, the method waits until a matching element appears in the DOM. If the element is detached during the actionability checks, the action is retried.
43094309
Shortcut for page.mainFrame().hover(selector[, options]).
43104310
@@ -4494,7 +4494,7 @@ async def check(
44944494
) -> NoneType:
44954495
"""Page.check
44964496
4497-
This method fetches an element with `selector`, if element is not already checked, it scrolls it into view if needed, and then uses page.click to click in the center of the element.
4497+
This method waits for an element matching `selector`, waits for actionability checks. Then, if the element is not already checked, this method scrolls the element into view and uses elementHandle.click to click in the center of the element.
44984498
If there's no element matching `selector`, the method waits until a matching element appears in the DOM. If the element is detached during the actionability checks, the action is retried.
44994499
Shortcut for page.mainFrame().check(selector[, options]).
45004500
@@ -4524,7 +4524,7 @@ async def uncheck(
45244524
) -> NoneType:
45254525
"""Page.uncheck
45264526
4527-
This method fetches an element with `selector`, if element is not already unchecked, it scrolls it into view if needed, and then uses page.click to click in the center of the element.
4527+
This method waits for an element matching `selector`, waits for actionability checks. Then, if the element is not already unchecked, this method scrolls the element into view and uses elementHandle.click to click in the center of the element.
45284528
If there's no element matching `selector`, the method waits until a matching element appears in the DOM. If the element is detached during the actionability checks, the action is retried.
45294529
Shortcut for page.mainFrame().uncheck(selector[, options]).
45304530
@@ -4574,7 +4574,7 @@ async def waitForFunction(
45744574
The `waitForFunction` can be used to observe viewport size change:
45754575
45764576
To pass an argument from Node.js to the predicate of `page.waitForFunction` function:
4577-
Shortcut for [page.mainFrame().waitForFunction(pageFunction, arg, options]])](#framewaitforfunctionpagefunction-arg-options).
4577+
Shortcut for page.mainFrame().waitForFunction(pageFunction[, arg, options]).
45784578
45794579
Parameters
45804580
----------

playwright/drivers/browsers.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
{
1010
"name": "firefox",
11-
"revision": "1144",
11+
"revision": "1154",
1212
"download": true
1313
},
1414
{

playwright/page.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,15 @@ async def screenshot(
539539
fullPage: bool = None,
540540
clip: FloatRect = None,
541541
) -> bytes:
542-
binary = await self._channel.send("screenshot", locals_to_params(locals()))
543-
return base64.b64decode(binary)
542+
params = locals_to_params(locals())
543+
if "path" in params:
544+
del params["path"]
545+
encoded_binary = await self._channel.send("screenshot", params)
546+
decoded_binary = base64.b64decode(encoded_binary)
547+
if path:
548+
with open(path, "wb") as fd:
549+
fd.write(decoded_binary)
550+
return decoded_binary
544551

545552
async def title(self) -> str:
546553
return await self._main_frame.title()
@@ -722,7 +729,8 @@ async def pdf(
722729
path: str = None,
723730
) -> bytes:
724731
params = locals_to_params(locals())
725-
del params["path"]
732+
if "path" in params:
733+
del params["path"]
726734
encoded_binary = await self._channel.send("pdf", params)
727735
decoded_binary = base64.b64decode(encoded_binary)
728736
if path:

0 commit comments

Comments
 (0)