Skip to content

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

docs: fix broken snippets in handles and API testing guides (#43096)

soreavis588714df14a4
diff --git a/docs/src/api-testing-js.md b/docs/src/api-testing-js.md
index 63ac024af7..0947affc68 100644
--- a/docs/src/api-testing-js.md
+++ b/docs/src/api-testing-js.md
@@ -264,7 +264,7 @@ test('last created issue should be on the server', async ({ page }) => {
`https://api.github.com/repos/${USER}/${REPO}/issues/${issueId}`
);
expect(newIssue.ok()).toBeTruthy();
- expect(newIssue.json()).toEqual(expect.objectContaining({
+ expect(await newIssue.json()).toEqual(expect.objectContaining({
title: 'Bug report 1'
}));
});
diff --git a/docs/src/handles.md b/docs/src/handles.md
index e170b60045..3fde723870 100644
--- a/docs/src/handles.md
+++ b/docs/src/handles.md
@@ -62,7 +62,7 @@ APIs wait for the element to be attached and visible.
```js
// Get the element handle
-const elementHandle = page.waitForSelector('#box');
+const elementHandle = await page.waitForSelector('#box');
// Assert bounding box for the element
const boundingBox = await elementHandle.boundingBox();
@@ -89,11 +89,11 @@ assertTrue(classNames.contains("highlighted"));
```python async
# Get the element handle
-element_handle = page.wait_for_selector('#box')
+element_handle = await page.wait_for_selector('#box')
# Assert bounding box for the element
bounding_box = await element_handle.bounding_box()
-assert bounding_box.width == 100
+assert bounding_box["width"] == 100
# Assert attribute for the element
class_names = await element_handle.get_attribute('class')
@@ -106,7 +106,7 @@ element_handle = page.wait_for_selector('#box')
# Assert bounding box for the element
bounding_box = element_handle.bounding_box()
-assert bounding_box.width == 100
+assert bounding_box["width"] == 100
# Assert attribute for the element
class_names = element_handle.get_attribute('class')