Purpose
Retrieve the basic Puppeteer example shown on the Browserless website, including the connection code needed to connect Puppeteer to Browserless.
When to Use
Use when the caller asks for a basic Puppeteer or Puppeteer-connect example for Browserless. This recipe returns the code displayed by the site's Puppeteer example panel rather than inventing connection details.
Workflow
- Navigate directly to
https://www.browserless.io/. - Open the expandable control whose accessible name or visible text is
Puppeteer. Prefer a role/name selector such asbuttonwith accessible namePuppeteer; do not hard-code the generated Radix element id. If the panel is already expanded, skip this step. - On the resulting page, run the following
evaluate()and return the matching code block(s):
(() => {
const clean = (value) => (value || "").replace(/\s+/g, " ").trim();
const blocks = [...document.querySelectorAll("pre")]
.map((el, index) => ({
index,
text: (el.innerText || el.textContent || "").trim(),
visible: !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length),
}))
.filter((block) => block.visible && block.text);
const matches = blocks.filter(({ text }) =>
/puppeteer|browserless|connect|websocket/i.test(text),
);
return {
examples: matches.length ? matches : blocks,
code: (matches.length ? matches : blocks).map(({ text }) => text),
};
})();Site-Specific Gotchas
- The Puppeteer example is revealed through an expandable UI control on the homepage; it is not necessarily visible in the initial DOM viewport.
- The control uses a generated Radix-style DOM id, so identify it by accessible name or visible text rather than an id such as
radix-...-trigger-puppeteer. - Code examples are rendered in
preelements. Filter visible blocks and prefer blocks mentioning Puppeteer, Browserless,connect, or a WebSocket connection because the page may contain multiple examples. - The Browserless homepage is directly reachable at
/; no homepage search or documentation navigation is required for this example. - Preserve the returned code exactly, including placeholders or environment-variable references, instead of substituting credentials or inventing a token.
Expected Output
Return the extracted Puppeteer example code, preferably as the code array from the evaluator, along with the structured examples entries when context such as the block index is useful.