Created
September 15, 2024 14:06
-
-
Save dracos/4d146b34d26b3c69d9fc72d63c57cfdf to your computer and use it in GitHub Desktop.
Revisions
-
dracos created this gist
Sep 15, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ import puppeteer from 'puppeteer'; import * as readline from 'node:readline/promises'; // Get the info we need const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); const username = await rl.question('Username: '); const password = await rl.question('Password: '); const code = await rl.question('OTP code: '); // Start a browser and a recording const browser = await puppeteer.launch({ headless: false }); const page = await browser.newPage(); const recorder = await page.screencast({path: 'recording.webm'}); // Get to the login page await page.goto('https://www.gov.uk/sign-in-childcare-account'); await page.locator('#get-started > a').click(); // Sign in await page.locator('#gov_gateway_start_now').click(); // Start now await page.locator('.govuk-cookie-banner button:nth-child(2)').click(); // Cookie banner, no // Login await page.locator('#user_id').click(); await page.evaluate(() => { document.getElementById('user_id').type = 'password'; }); // Makes sharing video easier! await page.locator('#user_id').fill(username); await page.locator('#password').fill(password); await page.locator('#continue').click(); // 2FA - might depend on what you have set up await page.locator('#factor1Ctl').click(); await page.locator('#continue').click(); await page.locator('#oneTimePassword').fill(code); await page.locator('#continue').click(); // Now just lots of buttons to click one at a time await page.locator('#welcome_info_continue').click(); await page.locator('#par_acc_homepage_reconfirmation').click(); await page.locator('#par_acc_reconfirmation_continue').click(); await page.locator('#par_app_summary_continue').click(); await page.locator('#par_acc_reconf_summ_declaration').click(); // There's a please wait page after confirmation const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); await delay(10000); await recorder.stop(); await browser.close();