const { clickElementBySelector } = require('./utils.js'); const { EDUFPMI_URL } = process.env; const launchUserSession = async (user, browser) => { const { username, password } = user; const page = await browser.newPage(); // Login await page.goto(EDUFPMI_URL, { waitUntil: 'domcontentloaded' }); await page.type('input#username', username); await page.type('input#password', password); await Promise.all([ clickElementBySelector(page, 'button#loginbtn'), page.waitForNavigation() ]); console.log(`Logged in as ${username}`); return page; }; module.exports = launchUserSession;