0

I'm trying to bypass a Hcaptcha with 2captcha thank to selenium and 2captcha in python.

When I receive my 2captcha token, I try to fill my token in both textareas named 'h-captcha-response' and 'g-captcha-response'

But it doesn't work.

Both textareas have ids with the pattern "h-captacha-[ID]" and "g-recaptacha-[ID]"

My problem is : As soon as I want to fill the innerHTML of the textareas, it returns me an error because I can't get the 2 items correctly

driver.execute_script('''                                                                                                                                                   
     let [captcha] = arguments[document.querySelectorAll('[name="h-captcha-response"], 
     [name="g-recaptcha-response"]')].map(el => {                                                          
     el.innerHTML = captcha})''', code)

Do you know why my driver.execute_script command doesn't work ? Code is the good token for the captcha, i need to send it in the 2 textareas.

Here is the error

selenium.common.exceptions.JavascriptException: Message: javascript error: Cannot read properties of undefined (reading 'map')

vimuth
  • 5,064
  • 33
  • 79
  • 116

1 Answers1

0

That js is getting mangled. This looks right to me

driver.execute_script('''                                                                                                                                                   
  let [captcha] = arguments
  let css = '[name="h-captcha-response"], [name="g-recaptcha-response"]'
  [...document.querySelectorAll(css)].map(el => {                                                          
    el.innerHTML = captcha
  })
''', code)
pguardiario
  • 53,827
  • 19
  • 119
  • 159