Java Selenium + 2Captcha + Submit Form

送分小仙女□ 提交于 2019-12-06 02:51:53

All you need to do is submit it like this:

js.executeScript("document.getElementById('g-recaptcha-response').innerHTML='" + responseToken + "';");
Thread.sleep(500);
js.executeScript("document.getElementById('captcha-form').submit();");

also don't forget to check this ID : "captcha-form", it can be different

To reach to element "recaptcha-verify-button":

After you got the response from the API;

By frame = By.xpath("//iframe[@title='recaptcha challenge']");

WebElement frameElement = driver.findElement(frame);

driver.switchTo.frame(frameElement);

then you can execute your script. Finally, for your script if your captcha form is a button

you

cannot call submit();

you

can call click();

Final Answer:

Also check this: js.executeScript("widgetVerified('TOKEN');");

To find the function called widgetVerified() please run this code in the console.

___grecaptcha_cfg.clients[0]

this will return a json, inside of that json try to find the callback function in @Awais case it was wigdetVerified(e)

Warn : Don't use any adblocker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!