Skip to content

Commit b77b4f4

Browse files
committed
feat: roll driver to 1.3.0-next.1596843106133, handle paths on the client side
1 parent 05e48f6 commit b77b4f4

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
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
[![Coverage Status](https://coveralls.io/repos/github/microsoft/playwright-python/badge.svg?branch=master)](https://coveralls.io/github/microsoft/playwright-python?branch=master)
55

66
##### [Docs](#documentation) | [API reference](https://github.com/microsoft/playwright/blob/master/docs/api.md)
@@ -11,7 +11,7 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
1111
| :--- | :---: | :---: | :---: |
1212
| Chromium <!-- GEN:chromium-version -->86.0.4217.0<!-- GEN:stop --> ||||
1313
| WebKit 14.0 ||||
14-
| Firefox <!-- GEN:firefox-version -->78.0b5<!-- GEN:stop --> ||||
14+
| Firefox <!-- GEN:firefox-version -->79.0a1<!-- GEN:stop --> ||||
1515

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

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/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:

tests/async/test_pdf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ async def test_should_be_able_to_save_pdf_file(page: Page, server, tmpdir: Path)
2525
output_file = tmpdir / "foo.png"
2626
await page.pdf(path=str(output_file))
2727
assert os.path.getsize(output_file) > 0
28+
29+
30+
@pytest.mark.only_browser("chromium")
31+
async def test_should_be_able_capture_pdf_without_path(page: Page):
32+
buffer = await page.pdf()
33+
assert buffer

tests/sync/test_pdf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ def test_should_be_able_to_save_pdf_file(page: Page, server, tmpdir: Path):
2525
output_file = tmpdir / "foo.png"
2626
page.pdf(path=str(output_file))
2727
assert os.path.getsize(output_file) > 0
28+
29+
30+
@pytest.mark.only_browser("chromium")
31+
def test_should_be_able_capture_pdf_without_path(page: Page):
32+
buffer = page.pdf()
33+
assert buffer

0 commit comments

Comments
 (0)