Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/content/docs/browser-rendering/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Changelog
changelog_file_name:
- browser-rendering
sidebar:
order: 8
order: 9
head: []
description: Review recent changes to Worker Browser Rendering.
---
Expand Down
50 changes: 50 additions & 0 deletions src/content/docs/browser-rendering/faq.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: FAQ
pcx_content_type: faq
sidebar:
order: 8
head:
- tag: title
content: Frequently asked questions about Cloudflare Browser Rendering
---

import { GlossaryTooltip } from "~/components";

Below you will find answers to our most commonly asked questions. If you cannot find the answer you are looking for, refer to the [Discord](https://discord.cloudflare.com) to explore additional resources.

##### 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 for Platforms Paid plan](/cloudflare-for-platforms/workers-for-platforms/platform/pricing/).

##### Will browser rendering bypass Cloudflare's Bot Protection?

Browser rendering requests are always identified as bots by Cloudflare.

## Puppeteer

##### 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` for example:

```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.

:::
2 changes: 1 addition & 1 deletion src/content/docs/browser-rendering/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { CardGrid, Description, LinkTitleCard, Plan, RelatedProduct } from "~/co

<Description>

Browser automation for [Cloudflare Workers](/workers/).
Browser automation for [Cloudflare Workers](/workers/).
</Description>

<Plan type="workers-paid" />
Expand Down
Loading