0

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()
    });

})();
Francis
  • 21
  • 3
  • I have tried doing something similar with stack overflow and I was able to log in. I don't know why this isn't working. – Francis Aug 21 '21 at 06:41

2 Answers2

1

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.

Francis
  • 21
  • 3
0

try to submit form instead of click on the button.

await page.$eval('form-selector', form => form.submit());
Nik B
  • 617
  • 6
  • 11