-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
title: FAQ | ||
pcx_content_type: faq | ||
sidebar: | ||
order: 8 | ||
head: | ||
- tag: title | ||
content: Frequently asked questions about Cloudflare Browser Rendering | ||
--- | ||
|
||
import { GlossaryTooltip } from "~/components"; | ||
|
||
## Common issues | ||
|
||
|
||
|
||
### Code generation from strings disallowed for this context while using an Xpath selector | ||
|
||
Currently it's not possible to use Xpath to select elements since this poses a security risk to Workers | ||
|
||
As an alternative try to use a css selector or `page.evaluate` | ||
|
||
```ts | ||
const innerHtml = await page.evaluate(() => { | ||
return ( | ||
// @ts-ignore this runs on browser context | ||
new XPathEvaluator() | ||
.createExpression("/html/body/div/h1") | ||
// @ts-ignore this runs on browser context | ||
.evaluate(document, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue | ||
.innerHTML | ||
); | ||
}); | ||
``` | ||
|
||
:::note | ||
|
||
Keep in mind that `page.evaluate` can only return primitive types like strings, numbers, etc. | ||
|
||
Returning an `HTMLElement` won't work. | ||
|
||
::: | ||
|
||
### Uncaught (in response) TypeError: Cannot read properties of undefined (reading 'fetch') | ||
|
||
Make sure that you are passing your Browser binding to the `puppeteer.launch` api and that you have **workers paid** plan. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters