mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
api(dotnet): use jsonelement (#6749)
This commit is contained in:
parent
c60974d922
commit
792f3d41e9
@ -98,27 +98,8 @@ function findFocusedNode(node) {
|
|||||||
```
|
```
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
static AccessibilitySnapshotResult findFocusedNode(AccessibilitySnapshotResult root)
|
|
||||||
{
|
|
||||||
var nodes = new Stack<AccessibilitySnapshotResult>(new[] { root });
|
|
||||||
while (nodes.Count > 0)
|
|
||||||
{
|
|
||||||
var node = nodes.Pop();
|
|
||||||
if (node.Focused) return node;
|
|
||||||
foreach (var innerNode in node.Children)
|
|
||||||
{
|
|
||||||
nodes.Push(innerNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var accessibilitySnapshot = await page.Accessibility.SnapshotAsync();
|
var accessibilitySnapshot = await page.Accessibility.SnapshotAsync();
|
||||||
Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(accessibilitySnapshot));
|
Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(accessibilitySnapshot));
|
||||||
var focusedNode = findFocusedNode(accessibilitySnapshot);
|
|
||||||
if (focusedNode != null)
|
|
||||||
Console.WriteLine(focusedNode.Name);
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```java
|
```java
|
||||||
|
|||||||
@ -32,7 +32,7 @@ This method will throw if the response body is not parsable via `JSON.parse`.
|
|||||||
|
|
||||||
## async method: Response.json
|
## async method: Response.json
|
||||||
* langs: csharp
|
* langs: csharp
|
||||||
- returns: <[JsonDocument]>
|
- returns: <[JsonElement?]>
|
||||||
|
|
||||||
Returns the JSON representation of response body.
|
Returns the JSON representation of response body.
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
## method: Request.PostDataJSON
|
## method: Request.PostDataJSON
|
||||||
* langs: csharp
|
* langs: csharp
|
||||||
- returns: <[JsonDocument]>
|
- returns: <[JsonElement?]>
|
||||||
|
|
||||||
Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any.
|
Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user