Socks
Socks5w ago

How to wait for page/iframe to load completely using Astral

EDIT: I think what I am looking for is How to wait for an iframe to load. I most recently tried using await page.waitForSelector('#duo_iframe') to wait for the ID of the iframe but this failed and timed out. --- I am using Astral instead of playwright or puppeteer which I would normally use with Node and Astral is very similar to playwright but I can't get it to properly wait for my page to load for all the content.
// Import Astral
import { launch } from "jsr:@astral/astral";

// Secure credentials
const C_USERNAME = "xxxxxxxx"
const C_PASSWORD = "xxxxxxxx"

// Launch the browser
const browser = await launch();

// Open a new page
const page = await browser.newPage("https://adminportal.xxxxxxxxx.com/Account/LogOn", { waitUntil: 'networkidle0' });

// Enter username
const username = await page.$("#UserName");
await username!.type(C_USERNAME);

// Enter password
const password = await page.$("#Password");
await password!.type(C_PASSWORD);

// Click the submit button
const submit = await page.$("#login > input[type=submit]:nth-child(9)");
await Promise.all([
page.waitForNavigation(),
submit!.click()
])

// Take a screenshot of the page and save that to disk
const screenshot2 = await page.screenshot();
Deno.writeFileSync("screenshot2.png", screenshot2);
// Import Astral
import { launch } from "jsr:@astral/astral";

// Secure credentials
const C_USERNAME = "xxxxxxxx"
const C_PASSWORD = "xxxxxxxx"

// Launch the browser
const browser = await launch();

// Open a new page
const page = await browser.newPage("https://adminportal.xxxxxxxxx.com/Account/LogOn", { waitUntil: 'networkidle0' });

// Enter username
const username = await page.$("#UserName");
await username!.type(C_USERNAME);

// Enter password
const password = await page.$("#Password");
await password!.type(C_PASSWORD);

// Click the submit button
const submit = await page.$("#login > input[type=submit]:nth-child(9)");
await Promise.all([
page.waitForNavigation(),
submit!.click()
])

// Take a screenshot of the page and save that to disk
const screenshot2 = await page.screenshot();
Deno.writeFileSync("screenshot2.png", screenshot2);
0 Replies
No replies yetBe the first to reply to this messageJoin