@@ -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