chore(dotnet): add examples to accessibility docs (#5702)
This commit is contained in:
parent
ad27f3bf02
commit
986286a396
|
|
@ -73,6 +73,11 @@ snapshot = page.accessibility.snapshot()
|
||||||
print(snapshot)
|
print(snapshot)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var accessibilitySnapshot = await Page.Accessibility.SnapshotAsync();
|
||||||
|
Console.WriteLine(accessibilitySnapshot);
|
||||||
|
```
|
||||||
|
|
||||||
An example of logging the focused node's name:
|
An example of logging the focused node's name:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|
@ -91,6 +96,29 @@ function findFocusedNode(node) {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
Func<AccessibilitySnapshotResult, AccessibilitySnapshotResult> findFocusedNode = 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 focusedNode = findFocusedNode(accessibilitySnapshot);
|
||||||
|
if(focusedNode != null)
|
||||||
|
Console.WriteLine(focusedNode.Name);
|
||||||
|
```
|
||||||
|
|
||||||
```java
|
```java
|
||||||
// FIXME
|
// FIXME
|
||||||
String snapshot = page.accessibility().snapshot();
|
String snapshot = page.accessibility().snapshot();
|
||||||
|
|
@ -127,7 +155,7 @@ if node:
|
||||||
```
|
```
|
||||||
|
|
||||||
## async method: Accessibility.snapshot
|
## async method: Accessibility.snapshot
|
||||||
* langs: csharp, java
|
* langs: java
|
||||||
- returns: <[null]|[string]>
|
- returns: <[null]|[string]>
|
||||||
|
|
||||||
### option: Accessibility.snapshot.interestingOnly
|
### option: Accessibility.snapshot.interestingOnly
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue