fnb-api icon indicating copy to clipboard operation
fnb-api copied to clipboard

Error: No element found for selector: #user

Open Hartjies opened this issue 1 year ago • 8 comments

fnb@ftp:~/api$ node main.js Error: No element found for selector: #user at assert (/home/fnb/api/node_modules/fnb-api/node_modules/puppeteer-core/lib/cjs/puppeteer/util/assert.js:28:15) at IsolatedWorld.type (/home/fnb/api/node_modules/fnb-api/node_modules/puppeteer-core/lib/cjs/puppeteer/common/IsolatedWorld.js:221:32) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

fnb@ftp:~/api$ npm list fnb-api [email protected] /home/fnb/api └── [email protected]

fnb@ftp:~/api$ npm show puppeteer-core version 22.0.0

Hartjies avatar Feb 13 '24 07:02 Hartjies

DevTool shows: <input type="text" placeholder="Username" id="user" name="Username" value="" tabindex="1" class=" userName"> <input type="password" placeholder="Password" id="pass" name="Password" value="" tabindex="2" class=" passWord">

Hartjies avatar Feb 13 '24 07:02 Hartjies

I think I fixed this by changing submit button. src/scrapers/scraper.ts

// await this._page.click('input[type="submit"]') await this._page.click('#OBSubmit');

Hartjies avatar Feb 13 '24 08:02 Hartjies

I think I fixed this by changing submit button. src/scrapers/scraper.ts

// await this._page.click('input[type="submit"]') await this._page.click('#OBSubmit');

This fixed the login for me, pls update repo

echo909 avatar Feb 13 '24 08:02 echo909

@AntonJanHart @echo909 thats unlikely what fixed it. The reason why #user is not found is because FNB now has some kind of DDOS protection, that shows up:

image

You'll see It appears the first time the site loads, then a cookie gets set and the page reloads. You can see it by clearing your cookies on FNB and reloading the page with javascript disabled.

I'm going to try add this before trying to type in a username:

await this._page.waitForSelector('#user', { timeout: 30000 });

circlingthesun avatar Mar 05 '24 18:03 circlingthesun

That does not appear to work

circlingthesun avatar Mar 05 '24 19:03 circlingthesun

Upon further inspection: image

The capcha doesn't show up on my local.

circlingthesun avatar Mar 06 '24 09:03 circlingthesun

K, so I worked around this by using 'puppeteer-extra-plugin-recaptcha' and 2captcha.

See: https://www.zenrows.com/blog/puppeteer-captcha-bypass#solver-plugin

image

circlingthesun avatar Mar 06 '24 11:03 circlingthesun

My case I didn't get a capcha, but the "verifing your browser", where setting user agent did the trick:

(async () => {
  const customUserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36';
  const api = new FnbApi({
    username: 'username',
    password: 'password',
    puppeteerOptions: {
      args: [
        '--user-agent=${customUserAgent}'
      ],
    }
  });

Hartjies avatar Aug 20 '24 09:08 Hartjies