Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: fixing example code in accessibility API docs (#12664)

Andrew Haywardab39cfcb1845
diff --git a/docs/src/api/class-accessibility.md b/docs/src/api/class-accessibility.md
index a7d6b11d23..f2c0c03171 100644
--- a/docs/src/api/class-accessibility.md
+++ b/docs/src/api/class-accessibility.md
@@ -91,7 +91,8 @@ function findFocusedNode(node) {
return node;
for (const child of node.children || []) {
const foundNode = findFocusedNode(child);
- return foundNode;
+ if (foundNode)
+ return foundNode;
}
return null;
}
@@ -113,7 +114,8 @@ def find_focused_node(node):
return node
for child in (node.get("children") or []):
found_node = find_focused_node(child)
- return found_node
+ if (found_node)
+ return found_node
return None
snapshot = await page.accessibility.snapshot()
@@ -128,7 +130,8 @@ def find_focused_node(node):
return node
for child in (node.get("children") or []):
found_node = find_focused_node(child)
- return found_node
+ if (found_node)
+ return found_node
return None
snapshot = page.accessibility.snapshot()
@@ -153,4 +156,4 @@ Prune uninteresting nodes from the tree. Defaults to `true`.
### option: Accessibility.snapshot.root
- `root` <[ElementHandle]>
-The root DOM element for the snapshot. Defaults to the whole page.
\ No newline at end of file
+The root DOM element for the snapshot. Defaults to the whole page.
diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts
index 4fddaf3930..34d8be250f 100644
--- a/packages/playwright-core/types/types.d.ts
+++ b/packages/playwright-core/types/types.d.ts
@@ -10661,7 +10661,8 @@ export interface Accessibility {
* return node;
* for (const child of node.children || []) {
* const foundNode = findFocusedNode(child);
- * return foundNode;
+ * if (foundNode)
+ * return foundNode;
* }
* return null;
* }