I'm not sure why, but it seems like some fields just don't work for me.
This is working fine for me on one site:
await page.click(USERNAME_SELECTOR);
await page.keyboard.type(CREDS.username);
await page.click(PASSWORD_SELECTOR);
await page.keyboard.type(CREDS.password);
await page.click(LOGIN_BUTTON_SELECTOR);
await page.waitForNavigation();
However, on https://app.member.virginpulse.com/, it doesn't seem to work for me. It should be simple enough as the input fields both have IDs (#username
and $password
)... however, it just doesn't seem to fill out properly.
const puppeteer = require('puppeteer');
const email = "foo@bar.com";
const password = "foopass";
const emailInputSel = "#username";
const passwordInputSel = "#password";
const signInButtonSel = ".login-submit input";
const homeUrl = "https://app.member.virginpulse.com";
async function run() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(homeUrl, {waitUntil: 'domcontentloaded'});
//----from here---
await page.waitFor(emailInputSel);
await page.$eval(emailInputSel, (e,v) => e.value = v, email);
await page.$eval(passwordInputSel, (e,v) => e.value = v, password);
//----to here----- i've tried several things
await page.screenshot({path: 'screenshot.png'});
...
Other things I've tried:
await page.evaluate((sel, val) => {
const ele = document.querySelector(sel);
if (!ele) {
return;
}
ele.value = val;
}, sel, val);
await page.evaluate((sel) => {
const ele = document.querySelector(sel);
if (!ele) {
return;
}
ele.click(); ele.focus();
}, sel);
await page.keyboard.type(val);
Nothing seems to fill out the data properly. Does anyone know what is happening and how to get this to work?