Reputation: 21
I didn't include my correct email and password. However, entering the wrong email and password and then clicking the log in button will still make the modal disappear.
Expected Result
I will be told that entered the wrong email and password combination and modal shouldn't disappear.
What happens instead?
The modal disappears.
Code
const puppeteer = require('puppeteer');
(async () => {
// const browser = await puppeteer.launch();
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.setViewport({
width: 1550,
height: 700,
deviceScaleFactor: 1,
});
await page.goto('https://splinterlands.com');
//click log in button to fill form
await page.$eval("#log_in_button button", (el)=>{
el.click()
});
//type username to username section
await page.$eval("input#email.form-control", (el)=>{
el.value = "@gmail.com"
});
//type password to password section
await page.$eval("input#password.form-control", (el)=>{
el.value = "b"
});
//click log in button to log in
await page.$eval(".form-horizontal button.btn.btn-primary.btn-lg", (el)=>{
el.click()
});
})();
Upvotes: 0
Views: 108
Reputation: 21
Delay the clicking of the log in button by turning this
await page.$eval(".form-horizontal button.btn.btn-primary.btn-lg", (el)=>{
el.click()
});
to this
await setTimeout( ()=>{
page.$eval(".form-horizontal button.btn.btn-primary.btn-lg", (el)=>{
el.click()
});
}, 1000);
Unfortunately, I have yet to understand why this works.
Upvotes: 1
Reputation: 647
try to submit form instead of click on the button.
await page.$eval('form-selector', form => form.submit());
Upvotes: 0