You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add Element selection section to Puppeteer documentation
- Explain XPath limitation and provide page.evaluate() workaround
- Remove duplicate XPath FAQ entry from FAQ page
- Improve information architecture by placing content in relevant context
Copy file name to clipboardExpand all lines: src/content/docs/browser-rendering/faq.mdx
-25Lines changed: 0 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,31 +54,6 @@ There is no fixed limit on the number of requests per browser session. A single
54
54
55
55
This error typically occurs because your Puppeteer launch is not receiving the Browser binding. To resolve: Pass your Browser binding into `puppeteer.launch`.
56
56
57
-
### Why can't I use an XPath selector when using Browser Rendering with Puppeteer?
58
-
59
-
Currently it is not possible to use Xpath to select elements since this poses a security risk to Workers.
60
-
61
-
As an alternative, try to use a css selector or `page.evaluate`. For example:
Copy file name to clipboardExpand all lines: src/content/docs/browser-rendering/platform/puppeteer.mdx
+26-1Lines changed: 26 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,32 @@ await page.setUserAgent(
68
68
```
69
69
70
70
:::note
71
-
The `userAgent` parameter does not bypass bot protection. Requests from Browser Rendering will always be identified as a bot.
71
+
The `userAgent` parameter does not bypass bot protection. Requests from Browser Rendering will always be identified as a bot.
72
+
:::
73
+
74
+
## Element selection
75
+
76
+
Puppeteer provides multiple methods for selecting elements on a page. While CSS selectors work as expected, XPath selectors are not supported due to security constraints in the Workers runtime.
77
+
78
+
Instead of using Xpath selectors, you can use CSS selectors or `page.evaluate()` to run XPath queries in the browser context:
0 commit comments