Public
Edited
Dec 13, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
api.tabs.query({})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
searchWord = listenForm(searchForm, { value : d => d.text } )
Insert cell
Insert cell
mutable automationResult = null;
Insert cell
withBrowser(api, async ({ browser }) => {
// use first page from pages instead of using browser.newPage()
const [page] = await browser.pages();
if (!page) return { error: "Can not find the first page in this window." };

await page.goto("https://wikipedia.org");

const englishButton = await page.waitForSelector("#js-link-box-en > strong");
await englishButton?.click();

const searchBox = await page.waitForSelector("#searchInput");
await searchBox?.type(searchWord);
await page.keyboard.press("Enter");

await Promises.delay(1000);

const headers = await page.evaluate(() => {
return [
...document.querySelectorAll("#bodyContent :is(h1, h2, h3, h4, h5, h6)")
].map((elm) => {
return {
tag: elm.tagName,
content: elm.innerText
};
});
});

const content = await page.$("#content");
const screenshot = await content?.screenshot({
encoding: "base64"
});
const screenshotUrl = `data:image/png;base64,${screenshot}`;

await Promises.delay(1000);
mutable automationResult = {
headers,
screenshotUrl
};
})
Insert cell
Insert cell
import {
loadApi,
listenForm,
newApiKeyInput
} from "@kotelnikov/webrun-devtools"
Insert cell
utils = import("@statewalker/utils")
Insert cell
WebRunPuppeteer = await import("@statewalker/webrun-puppeteer")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more