sisa-crawl/login.js
2024-11-20 15:33:02 +01:00

45 lines
1.4 KiB
JavaScript

const { email, password, webpage } = require("./vars.js");
async function runLoginScript(browser) {
try {
const page = await browser.newPage();
// Navigate to the login page
await page.goto(webpage);
// Wait for 5 seconds
await page.waitForSelector(".form-control[type=\'email\']");
// Enter the email
await page.type(".form-control[type='email']", email);
console.log("email entered");
// Wait for 5 seconds
/* await new Promise((resolve) => setTimeout(resolve, 5000)); */
//press enter keyboard
await page.keyboard.press("Enter");
// Wait for 5 seconds
/*await new Promise((resolve) => setTimeout(resolve, 5000));*/
await page.waitForSelector(".form-control[type='password']");
// Enter the password
await page.type(".form-control[type='password']", password);
console.log("password entered");
await page.keyboard.press("Enter");
// Wait for 5 seconds
await new Promise((resolve) => setTimeout(resolve, 5000));
// wait for the user to input the google auth code
console.log("waiting for auth code");
await new Promise((resolve) => setTimeout(resolve, 15000));
return page
} catch (error) {
console.error("An error occurred:", error);
}
}
module.exports = runLoginScript;