@@ -5748,27 +5748,27 @@ async def expose_function(self, name: str, callback: typing.Callable) -> NoneTyp
5748
5748
5749
5749
> NOTE: Functions installed via `page.expose_function()` survive navigations.
5750
5750
5751
- An example of adding an `sha1 ` function to the page:
5751
+ An example of adding a `sha256 ` function to the page:
5752
5752
5753
5753
```py
5754
5754
import asyncio
5755
5755
import hashlib
5756
5756
from playwright.async_api import async_playwright
5757
5757
5758
- async def sha1 (text):
5759
- m = hashlib.sha1 ()
5758
+ def sha256 (text):
5759
+ m = hashlib.sha256 ()
5760
5760
m.update(bytes(text, \" utf8\" ))
5761
5761
return m.hexdigest()
5762
5762
5763
5763
async def run(playwright):
5764
5764
webkit = playwright.webkit
5765
5765
browser = await webkit.launch(headless=False)
5766
5766
page = await browser.new_page()
5767
- await page.expose_function(\" sha1 \" , sha1 )
5767
+ await page.expose_function(\" sha256 \" , sha256 )
5768
5768
await page.set_content(\" \" \"
5769
5769
<script>
5770
5770
async function onClick() {
5771
- document.querySelector('div').textContent = await window.sha1 ('PLAYWRIGHT');
5771
+ document.querySelector('div').textContent = await window.sha256 ('PLAYWRIGHT');
5772
5772
}
5773
5773
</script>
5774
5774
<button onclick=\" onClick()\" >Click me</button>
@@ -8531,28 +8531,28 @@ async def expose_function(self, name: str, callback: typing.Callable) -> NoneTyp
8531
8531
8532
8532
See `page.expose_function()` for page-only version.
8533
8533
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:
8535
8535
8536
8536
```py
8537
8537
import asyncio
8538
8538
import hashlib
8539
8539
from playwright.async_api import async_playwright
8540
8540
8541
- async def sha1 (text):
8542
- m = hashlib.sha1 ()
8541
+ def sha256 (text):
8542
+ m = hashlib.sha256 ()
8543
8543
m.update(bytes(text, \" utf8\" ))
8544
8544
return m.hexdigest()
8545
8545
8546
8546
async def run(playwright):
8547
8547
webkit = playwright.webkit
8548
8548
browser = await webkit.launch(headless=False)
8549
8549
context = await browser.new_context()
8550
- await context.expose_function(\" sha1 \" , sha1 )
8550
+ await context.expose_function(\" sha256 \" , sha256 )
8551
8551
page = await context.new_page()
8552
8552
await page.set_content(\" \" \"
8553
8553
<script>
8554
8554
async function onClick() {
8555
- document.querySelector('div').textContent = await window.sha1 ('PLAYWRIGHT');
8555
+ document.querySelector('div').textContent = await window.sha256 ('PLAYWRIGHT');
8556
8556
}
8557
8557
</script>
8558
8558
<button onclick=\" onClick()\" >Click me</button>
@@ -9393,7 +9393,7 @@ async def launch(
9393
9393
proxy : ProxySettings = None ,
9394
9394
downloads_path : typing .Union [str , pathlib .Path ] = None ,
9395
9395
slow_mo : float = None ,
9396
- trace_dir : typing .Union [str , pathlib .Path ] = None ,
9396
+ traces_dir : typing .Union [str , pathlib .Path ] = None ,
9397
9397
chromium_sandbox : bool = None ,
9398
9398
firefox_user_prefs : typing .Optional [
9399
9399
typing .Dict [str , typing .Union [str , float , bool ]]
@@ -9468,7 +9468,7 @@ async def launch(
9468
9468
deleted when browser is closed.
9469
9469
slow_mo : Union[float, NoneType]
9470
9470
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]
9472
9472
If specified, traces are saved into this directory.
9473
9473
chromium_sandbox : Union[bool, NoneType]
9474
9474
Enable Chromium sandboxing. Defaults to `false`.
@@ -9499,7 +9499,7 @@ async def launch(
9499
9499
proxy = proxy ,
9500
9500
downloadsPath = downloads_path ,
9501
9501
slowMo = slow_mo ,
9502
- traceDir = trace_dir ,
9502
+ tracesDir = traces_dir ,
9503
9503
chromiumSandbox = chromium_sandbox ,
9504
9504
firefoxUserPrefs = mapping .to_impl (firefox_user_prefs ),
9505
9505
),
@@ -9544,7 +9544,7 @@ async def launch_persistent_context(
9544
9544
color_scheme : Literal ["dark" , "light" , "no-preference" ] = None ,
9545
9545
reduced_motion : Literal ["no-preference" , "reduce" ] = None ,
9546
9546
accept_downloads : bool = None ,
9547
- trace_dir : typing .Union [str , pathlib .Path ] = None ,
9547
+ traces_dir : typing .Union [str , pathlib .Path ] = None ,
9548
9548
chromium_sandbox : bool = None ,
9549
9549
record_har_path : typing .Union [str , pathlib .Path ] = None ,
9550
9550
record_har_omit_content : bool = None ,
@@ -9652,7 +9652,7 @@ async def launch_persistent_context(
9652
9652
`page.emulate_media()` for more details. Defaults to `'no-preference'`.
9653
9653
accept_downloads : Union[bool, NoneType]
9654
9654
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]
9656
9656
If specified, traces are saved into this directory.
9657
9657
chromium_sandbox : Union[bool, NoneType]
9658
9658
Enable Chromium sandboxing. Defaults to `false`.
@@ -9714,7 +9714,7 @@ async def launch_persistent_context(
9714
9714
colorScheme = color_scheme ,
9715
9715
reducedMotion = reduced_motion ,
9716
9716
acceptDownloads = accept_downloads ,
9717
- traceDir = trace_dir ,
9717
+ tracesDir = traces_dir ,
9718
9718
chromiumSandbox = chromium_sandbox ,
9719
9719
recordHarPath = record_har_path ,
9720
9720
recordHarOmitContent = record_har_omit_content ,
@@ -9944,14 +9944,14 @@ async def start(
9944
9944
await context.tracing.start(name=\" trace\" , screenshots=True, snapshots=True)
9945
9945
await page.goto(\" https://playwright.dev\" )
9946
9946
await context.tracing.stop()
9947
- await context.tracing.export( \" trace.zip\" )
9947
+ await context.tracing.stop(path = \" trace.zip\" )
9948
9948
```
9949
9949
9950
9950
Parameters
9951
9951
----------
9952
9952
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()`.
9955
9955
snapshots : Union[bool, NoneType]
9956
9956
Whether to capture DOM snapshot on every action.
9957
9957
screenshots : Union[bool, NoneType]
@@ -9967,29 +9967,19 @@ async def start(
9967
9967
)
9968
9968
)
9969
9969
9970
- async def stop (self ) -> NoneType :
9970
+ async def stop (self , * , path : typing . Union [ str , pathlib . Path ] = None ) -> NoneType :
9971
9971
"""Tracing.stop
9972
9972
9973
9973
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.
9984
9974
9985
9975
Parameters
9986
9976
----------
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 .
9989
9979
"""
9990
9980
9991
9981
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 ))
9993
9983
)
9994
9984
9995
9985
0 commit comments