Open lmtr0 opened 9 months ago
deno-puppeteer
is no longer needed as npm support made it unnecessary, this works, however note the comment about an error below in the working sample where in my current use it fails half the time;
/* deno test -A puppet.js
deno.json
{ "nodeModulesDir": "auto" }
*/
import puppeteer from 'npm:puppeteer-core';
import { assert } from "jsr:@std/assert";
const browser = await puppeteer.launch({
slowMo: 250,
devtools: true,
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
});
const [page] = await browser.pages();
const gotoResult = await page.goto('https://deno.com').catch((err) => err);
if (gotoResult instanceof Error) {
/* 2024-11
problem with error "Not implemented: ClientRequest.options.createConnection"
https://github.com/denoland/deno/issues/19507
*/
const { message = '?!' } = gotoResult;
console.error(`error... "${message}" ${
message.includes('detached') ? 'see https://github.com/denoland/deno/issues/19507' : ''
}`);
await browser.close();
Deno.exit(1);
}
const text = await page.evaluate(() => {
return document.body.querySelector('main h1')?.textContent ?? '';
});
console.log({text});
Deno.test('test stuff', async ()=>{
assert(text.includes('JavaScript'), 'has JavaScript');
});
await browser.close();
previously: because it appears this repo is no longer maintained I moved to Astral at https://github.com/lino-levan/astral a quick demo seems to work:
import { launch } from "jsr:@astral/astral";
const browser = await launch({
headless: false,
path: '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
});
const page = await browser.newPage("https://deno.com");
const screenshot = await page.screenshot();
Deno.writeFileSync("screenshot.png", screenshot);
await browser.close();
now moving on to do something useful with it... hope this helps
thx
I would leave this issue open. This would provide it more visibility I guess
I gues so, but I would recommend people to move to the official Puppeteer library as deno supports NPM now
Isn't that it has always been supporting npm?
Hi there, I'm considering this project for a production product, is this still maintained?