berstend / puppeteer-extra

💯 Teach puppeteer new tricks through plugins.
https://extra.community
MIT License
6.23k stars 732 forks source link

[Bug] second recaptcha not solved on Goolge demo page with code from docs here #780

Closed andrisi closed 1 year ago

andrisi commented 1 year ago

Describe the bug

The plugin does not solve the second recaptcha, not even on the Google demo page. Tried in Puppeteer and Playwright too.

Code Snippet


import puppeteer from 'puppeteer-extra'
import RecaptchaPlugin from 'puppeteer-extra-plugin-recaptcha'
import {executablePath} from 'puppeteer'

puppeteer.use(
  RecaptchaPlugin({
    provider: {
        id: '2captcha',
        token: 'xxxxxxx'
    },
    visualFeedback: true
  })
)

puppeteer.launch({ headless: false, executablePath: executablePath() }).then(async browser => {

  const page = await browser.newPage()

  await page.goto('https://www.google.com/recaptcha/api2/demo')

  await page.solveRecaptchas()

  await Promise.all([
    page.waitForNavigation(),
    page.click(`#recaptcha-demo-submit`)
  ])

  await page.screenshot({ path: 'response1.png', fullPage: true })

  await page.goto('https://www.google.com/')

  await page.goto('https://www.google.com/recaptcha/api2/demo')

  await Promise.all([
    page.waitForNavigation(),
    page.click(`#recaptcha-demo-submit`)
  ])
  await page.screenshot({ path: 'response2.png', fullPage: true })

  await browser.close()
})

Versions

"dependencies": {
    "playwright": "1.31",
    "playwright-extra": "^4.3.6",
    "puppeteer": "^19.7.2",
    "puppeteer-core": "^19.7.2",
    "puppeteer-extra": "^3.3.6",
    "puppeteer-extra-plugin-recaptcha": "^3.6",
    "puppeteer-extra-plugin-stealth": "^2.11.2"
}
berstend commented 1 year ago

Looks like you forgot calling await page.solveRecaptchas() after the second/third page.goto?

andrisi commented 1 year ago

@berstend thanks for getting back to me. The issue was that I misunderstood the docs. You need the captcha on the screen, and then call the solveRecaptchas function, and every time. Somehow I thought you call it once, and it watches for any new captchas appearing on screen. Perhaps you could clarify this there. Thanks!