From 445404abb7057e9e0a3a54c31a501027a9ed1d1e Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 28 Oct 2022 09:58:54 -0700 Subject: [PATCH] docs: fix dotnet RegisterAsync/python jshandle example (#18408) Fixes https://github.com/microsoft/playwright-dotnet/issues/2359 Fixes https://github.com/microsoft/playwright-python/issues/1607 --- docs/src/api/class-jshandle.md | 4 ++-- docs/src/api/class-selectors.md | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/docs/src/api/class-jshandle.md b/docs/src/api/class-jshandle.md index ec321d27c1..37467beab0 100644 --- a/docs/src/api/class-jshandle.md +++ b/docs/src/api/class-jshandle.md @@ -140,7 +140,7 @@ handle.dispose(); ``` ```python async -handle = await page.evaluate_handle("{window, document}") +handle = await page.evaluate_handle("({window, document})") properties = await handle.get_properties() window_handle = properties.get("window") document_handle = properties.get("document") @@ -148,7 +148,7 @@ await handle.dispose() ``` ```python sync -handle = page.evaluate_handle("{window, document}") +handle = page.evaluate_handle("({window, document})") properties = handle.get_properties() window_handle = properties.get("window") document_handle = properties.get("document") diff --git a/docs/src/api/class-selectors.md b/docs/src/api/class-selectors.md index 9b4705e1d3..d6fe8381fd 100644 --- a/docs/src/api/class-selectors.md +++ b/docs/src/api/class-selectors.md @@ -145,18 +145,23 @@ with sync_playwright() as playwright: ``` ```csharp +using Microsoft.Playwright; + using var playwright = await Playwright.CreateAsync(); // Script that evaluates to a selector engine instance. The script is evaluated in the page context. -await playwright.Selectors.RegisterAsync("tag", @"{ -// Returns the first element matching given selector in the root's subtree. -query(root, selector) { - return root.querySelector(selector); - }, - // Returns all elements matching given selector in the root's subtree. - queryAll(root, selector) { - return Array.from(root.querySelectorAll(selector)); - } -}"); +await playwright.Selectors.RegisterAsync("tag", new() +{ + Script = @"{ + // Returns the first element matching given selector in the root's subtree. + query(root, selector) { + return root.querySelector(selector); + }, + // Returns all elements matching given selector in the root's subtree. + queryAll(root, selector) { + return Array.from(root.querySelectorAll(selector)); + } + }" +}); await using var browser = await playwright.Chromium.LaunchAsync(); var page = await browser.NewPageAsync();