Skip to content

Commit 06a62bb

Browse files
authored
chore: roll driver, fix real bugs (#740)
1 parent f4ec7c6 commit 06a62bb

File tree

8 files changed

+88
-98
lines changed

8 files changed

+88
-98
lines changed

README.md

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

77
| | Linux | macOS | Windows |
88
| :--- | :---: | :---: | :---: |
9-
| Chromium <!-- GEN:chromium-version -->92.0.4513.0<!-- GEN:stop --> ||||
9+
| Chromium <!-- GEN:chromium-version -->93.0.4530.0<!-- GEN:stop --> ||||
1010
| WebKit <!-- GEN:webkit-version -->14.2<!-- GEN:stop --> ||||
1111
| Firefox <!-- GEN:firefox-version -->89.0b15<!-- GEN:stop --> ||||
1212

playwright/_impl/_browser_type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ async def launch(
7676
proxy: ProxySettings = None,
7777
downloadsPath: Union[str, Path] = None,
7878
slowMo: float = None,
79-
traceDir: Union[pathlib.Path, str] = None,
79+
tracesDir: Union[pathlib.Path, str] = None,
8080
chromiumSandbox: bool = None,
8181
firefoxUserPrefs: Dict[str, Union[str, float, bool]] = None,
8282
) -> Browser:
@@ -126,7 +126,7 @@ async def launch_persistent_context(
126126
colorScheme: ColorScheme = None,
127127
reducedMotion: ReducedMotion = None,
128128
acceptDownloads: bool = None,
129-
traceDir: Union[pathlib.Path, str] = None,
129+
tracesDir: Union[pathlib.Path, str] = None,
130130
chromiumSandbox: bool = None,
131131
recordHarPath: Union[Path, str] = None,
132132
recordHarOmitContent: bool = None,

playwright/_impl/_tracing.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ def __init__(self, context: "BrowserContext") -> None:
2828
self._context = context
2929
self._channel = context._channel
3030
self._loop = context._loop
31+
self._dispatcher_fiber = context._channel._connection._dispatcher_fiber
3132

3233
async def start(
3334
self, name: str = None, snapshots: bool = None, screenshots: bool = None
3435
) -> None:
3536
params = locals_to_params(locals())
3637
await self._channel.send("tracingStart", params)
3738

38-
async def stop(self) -> None:
39+
async def stop(self, path: Union[pathlib.Path, str] = None) -> None:
3940
await self._channel.send("tracingStop")
40-
41-
async def export(self, path: Union[pathlib.Path, str]) -> None:
42-
artifact = cast(
43-
Artifact, from_channel(await self._channel.send("tracingExport"))
44-
)
45-
if self._context._browser:
46-
artifact._is_remote = self._context._browser._is_remote
47-
await artifact.save_as(path)
48-
await artifact.delete()
41+
if path:
42+
artifact = cast(
43+
Artifact, from_channel(await self._channel.send("tracingExport"))
44+
)
45+
if self._context._browser:
46+
artifact._is_remote = self._context._browser._is_remote
47+
await artifact.save_as(path)
48+
await artifact.delete()

playwright/async_api/_generated.py

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5748,27 +5748,27 @@ async def expose_function(self, name: str, callback: typing.Callable) -> NoneTyp
57485748
57495749
> NOTE: Functions installed via `page.expose_function()` survive navigations.
57505750
5751-
An example of adding an `sha1` function to the page:
5751+
An example of adding a `sha256` function to the page:
57525752
57535753
```py
57545754
import asyncio
57555755
import hashlib
57565756
from playwright.async_api import async_playwright
57575757
5758-
async def sha1(text):
5759-
m = hashlib.sha1()
5758+
def sha256(text):
5759+
m = hashlib.sha256()
57605760
m.update(bytes(text, \"utf8\"))
57615761
return m.hexdigest()
57625762
57635763
async def run(playwright):
57645764
webkit = playwright.webkit
57655765
browser = await webkit.launch(headless=False)
57665766
page = await browser.new_page()
5767-
await page.expose_function(\"sha1\", sha1)
5767+
await page.expose_function(\"sha256\", sha256)
57685768
await page.set_content(\"\"\"
57695769
<script>
57705770
async function onClick() {
5771-
document.querySelector('div').textContent = await window.sha1('PLAYWRIGHT');
5771+
document.querySelector('div').textContent = await window.sha256('PLAYWRIGHT');
57725772
}
57735773
</script>
57745774
<button onclick=\"onClick()\">Click me</button>
@@ -8531,28 +8531,28 @@ async def expose_function(self, name: str, callback: typing.Callable) -> NoneTyp
85318531
85328532
See `page.expose_function()` for page-only version.
85338533
8534-
An example of adding an `md5` function to all pages in the context:
8534+
An example of adding a `sha256` function to all pages in the context:
85358535
85368536
```py
85378537
import asyncio
85388538
import hashlib
85398539
from playwright.async_api import async_playwright
85408540
8541-
async def sha1(text):
8542-
m = hashlib.sha1()
8541+
def sha256(text):
8542+
m = hashlib.sha256()
85438543
m.update(bytes(text, \"utf8\"))
85448544
return m.hexdigest()
85458545
85468546
async def run(playwright):
85478547
webkit = playwright.webkit
85488548
browser = await webkit.launch(headless=False)
85498549
context = await browser.new_context()
8550-
await context.expose_function(\"sha1\", sha1)
8550+
await context.expose_function(\"sha256\", sha256)
85518551
page = await context.new_page()
85528552
await page.set_content(\"\"\"
85538553
<script>
85548554
async function onClick() {
8555-
document.querySelector('div').textContent = await window.sha1('PLAYWRIGHT');
8555+
document.querySelector('div').textContent = await window.sha256('PLAYWRIGHT');
85568556
}
85578557
</script>
85588558
<button onclick=\"onClick()\">Click me</button>
@@ -9393,7 +9393,7 @@ async def launch(
93939393
proxy: ProxySettings = None,
93949394
downloads_path: typing.Union[str, pathlib.Path] = None,
93959395
slow_mo: float = None,
9396-
trace_dir: typing.Union[str, pathlib.Path] = None,
9396+
traces_dir: typing.Union[str, pathlib.Path] = None,
93979397
chromium_sandbox: bool = None,
93989398
firefox_user_prefs: typing.Optional[
93999399
typing.Dict[str, typing.Union[str, float, bool]]
@@ -9468,7 +9468,7 @@ async def launch(
94689468
deleted when browser is closed.
94699469
slow_mo : Union[float, NoneType]
94709470
Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
9471-
trace_dir : Union[pathlib.Path, str, NoneType]
9471+
traces_dir : Union[pathlib.Path, str, NoneType]
94729472
If specified, traces are saved into this directory.
94739473
chromium_sandbox : Union[bool, NoneType]
94749474
Enable Chromium sandboxing. Defaults to `false`.
@@ -9499,7 +9499,7 @@ async def launch(
94999499
proxy=proxy,
95009500
downloadsPath=downloads_path,
95019501
slowMo=slow_mo,
9502-
traceDir=trace_dir,
9502+
tracesDir=traces_dir,
95039503
chromiumSandbox=chromium_sandbox,
95049504
firefoxUserPrefs=mapping.to_impl(firefox_user_prefs),
95059505
),
@@ -9544,7 +9544,7 @@ async def launch_persistent_context(
95449544
color_scheme: Literal["dark", "light", "no-preference"] = None,
95459545
reduced_motion: Literal["no-preference", "reduce"] = None,
95469546
accept_downloads: bool = None,
9547-
trace_dir: typing.Union[str, pathlib.Path] = None,
9547+
traces_dir: typing.Union[str, pathlib.Path] = None,
95489548
chromium_sandbox: bool = None,
95499549
record_har_path: typing.Union[str, pathlib.Path] = None,
95509550
record_har_omit_content: bool = None,
@@ -9652,7 +9652,7 @@ async def launch_persistent_context(
96529652
`page.emulate_media()` for more details. Defaults to `'no-preference'`.
96539653
accept_downloads : Union[bool, NoneType]
96549654
Whether to automatically download all the attachments. Defaults to `false` where all the downloads are canceled.
9655-
trace_dir : Union[pathlib.Path, str, NoneType]
9655+
traces_dir : Union[pathlib.Path, str, NoneType]
96569656
If specified, traces are saved into this directory.
96579657
chromium_sandbox : Union[bool, NoneType]
96589658
Enable Chromium sandboxing. Defaults to `false`.
@@ -9714,7 +9714,7 @@ async def launch_persistent_context(
97149714
colorScheme=color_scheme,
97159715
reducedMotion=reduced_motion,
97169716
acceptDownloads=accept_downloads,
9717-
traceDir=trace_dir,
9717+
tracesDir=traces_dir,
97189718
chromiumSandbox=chromium_sandbox,
97199719
recordHarPath=record_har_path,
97209720
recordHarOmitContent=record_har_omit_content,
@@ -9944,14 +9944,14 @@ async def start(
99449944
await context.tracing.start(name=\"trace\", screenshots=True, snapshots=True)
99459945
await page.goto(\"https://playwright.dev\")
99469946
await context.tracing.stop()
9947-
await context.tracing.export(\"trace.zip\")
9947+
await context.tracing.stop(path = \"trace.zip\")
99489948
```
99499949
99509950
Parameters
99519951
----------
99529952
name : Union[str, NoneType]
9953-
If specified, the trace is going to be saved into the file with the given name inside the `traceDir` folder specified in
9954-
`browser_type.launch()`.
9953+
If specified, the trace is going to be saved into the file with the given name inside the `tracesDir` folder specified
9954+
in `browser_type.launch()`.
99559955
snapshots : Union[bool, NoneType]
99569956
Whether to capture DOM snapshot on every action.
99579957
screenshots : Union[bool, NoneType]
@@ -9967,29 +9967,19 @@ async def start(
99679967
)
99689968
)
99699969

9970-
async def stop(self) -> NoneType:
9970+
async def stop(self, *, path: typing.Union[str, pathlib.Path] = None) -> NoneType:
99719971
"""Tracing.stop
99729972
99739973
Stop tracing.
9974-
"""
9975-
9976-
return mapping.from_maybe_impl(
9977-
await self._async("tracing.stop", self._impl_obj.stop())
9978-
)
9979-
9980-
async def export(self, path: typing.Union[pathlib.Path, str]) -> NoneType:
9981-
"""Tracing.export
9982-
9983-
Export trace into the file with the given name. Should be called after the tracing has stopped.
99849974
99859975
Parameters
99869976
----------
9987-
path : Union[pathlib.Path, str]
9988-
File to save the trace into.
9977+
path : Union[pathlib.Path, str, NoneType]
9978+
Export trace into the file with the given name.
99899979
"""
99909980

99919981
return mapping.from_maybe_impl(
9992-
await self._async("tracing.export", self._impl_obj.export(path=path))
9982+
await self._async("tracing.stop", self._impl_obj.stop(path=path))
99939983
)
99949984

99959985

0 commit comments

Comments
 (0)