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
|
```python async
|
||||||
handle = await page.evaluate_handle("{window, document}")
|
handle = await page.evaluate_handle("({window, document})")
|
||||||
properties = await handle.get_properties()
|
properties = await handle.get_properties()
|
||||||
window_handle = properties.get("window")
|
window_handle = properties.get("window")
|
||||||
document_handle = properties.get("document")
|
document_handle = properties.get("document")
|
||||||
|
|
@ -148,7 +148,7 @@ await handle.dispose()
|
||||||
```
|
```
|
||||||
|
|
||||||
```python sync
|
```python sync
|
||||||
handle = page.evaluate_handle("{window, document}")
|
handle = page.evaluate_handle("({window, document})")
|
||||||
properties = handle.get_properties()
|
properties = handle.get_properties()
|
||||||
window_handle = properties.get("window")
|
window_handle = properties.get("window")
|
||||||
document_handle = properties.get("document")
|
document_handle = properties.get("document")
|
||||||
|
|
|
||||||
|
|
@ -145,18 +145,23 @@ with sync_playwright() as playwright:
|
||||||
```
|
```
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
|
using Microsoft.Playwright;
|
||||||
|
|
||||||
using var playwright = await Playwright.CreateAsync();
|
using var playwright = await Playwright.CreateAsync();
|
||||||
// Script that evaluates to a selector engine instance. The script is evaluated in the page context.
|
// Script that evaluates to a selector engine instance. The script is evaluated in the page context.
|
||||||
await playwright.Selectors.RegisterAsync("tag", @"{
|
await playwright.Selectors.RegisterAsync("tag", new()
|
||||||
// Returns the first element matching given selector in the root's subtree.
|
{
|
||||||
query(root, selector) {
|
Script = @"{
|
||||||
return root.querySelector(selector);
|
// Returns the first element matching given selector in the root's subtree.
|
||||||
},
|
query(root, selector) {
|
||||||
// Returns all elements matching given selector in the root's subtree.
|
return root.querySelector(selector);
|
||||||
queryAll(root, selector) {
|
},
|
||||||
return Array.from(root.querySelectorAll(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();
|
await using var browser = await playwright.Chromium.LaunchAsync();
|
||||||
var page = await browser.NewPageAsync();
|
var page = await browser.NewPageAsync();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue