I'm trying to learn about 2Captcha nad as an example i wanted to make a spotify account. I've gotten to fill the form just right, but the only concern is the 2Captcha. I've tried all sorts of ways found on here but none of them worked. I've tried:
- ___grecaptcha_cfg.clients[0].bL.K.callback('token');
- window.captchaSuccessCallback(); (this was found in grecaptcha.render method)
- And this was my last approach:
val captcha = driver.findElement(By.id("captcha-div"))
val siteKey = captcha?.getAttribute("data-sitekey") ?: ""
println("Site key: $siteKey")
val solvedCaptcha = getCaptcha(siteKey, "2captchaKey", driver.currentUrl)
val js = driver as JavascriptExecutor
println(solvedCaptcha)
js.executeScript("document.getElementById('g-recaptcha-response').innerHTML='$solvedCaptcha';")
Thread.sleep(500)
val iframe = driver.findElement(By.xpath("//iframe[@title='recaptcha challenge']"))
println(iframe.toString())
driver.switchTo().frame(iframe)
js.executeScript("document.getElementById('recaptcha-verify-button').click();")
the url i'm using is Here
Updated code (still not working) added simulating keystrokes in hopes that maybe the callback would get triggered after detecting any key presses:
val captcha = driver.findElement(By.id("captcha-div"))
val siteKey = captcha?.getAttribute("data-sitekey") ?: ""
println("Site key: $siteKey")
val js = driver as JavascriptExecutor
val findElement = driver.findElement(By.id("g-recaptcha-response"))
js.executeScript("document.getElementById(\"g-recaptcha-response\").style.display = \"inline\";")
val solvedCaptcha = getCaptcha(siteKey, "captchaKey", driver.currentUrl)
println(solvedCaptcha)
solvedCaptcha?.forEach {
findElement.sendKeys(it.toString())
Thread.sleep(Random.nextLong(5L, 30L))
}
Thread.sleep(10000)