Socks
Socks
DDeno
Created by Socks on 9/9/2024 in #help
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);
1 replies
DDeno
Created by Socks on 4/16/2024 in #help
Deno compile not able to create files?
I want to create a simple CLI for a colleague at work that outputs a CSV file but I cannot seem to get Deno to create a file, even with the simplest of tests. When I run this normally using Deno run -A index.ts it will work as intended but when compiled and run through the executable it will run successfully but no file is created. Target OS: Windows Dev OS: Mac M1 (arm) CODE
async function main() {
await Deno.writeTextFile("hello.txt", "Hello World\n");
}
main()
async function main() {
await Deno.writeTextFile("hello.txt", "Hello World\n");
}
main()
Compile Command
Deno compile -A index.ts
Deno compile -A index.ts
7 replies