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:
parent
8e9540b7c1
commit
445404abb7
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue