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
This commit is contained in:
Max Schmitt 2022-10-28 09:58:54 -07:00 committed by GitHub
parent 8e9540b7c1
commit 445404abb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 12 deletions

View file

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

View file

@ -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();