Make use of the ‘input‘ tag with type ‘hidden‘ in-order to handle Captcha.
Look at this example for reference..
driver.get("http://www.google.com/recaptcha/learnmore");
driver.switchTo().frame(0); //calling iframe with no id
javascriptExecutor js = (JavascriptExecutor) driver;
//Setting the captcha values
js.executeScript("document.getElementsByName(‘recaptcha_challenge_field‘)[0].setAttribute(‘value‘,‘03AHJ_Vuv4tV3FrmUHbImL9JPkWJNqs1KDbFdKfG1jhqa2Uhl4U1vzLxXtZMMkZoAHuVCXA1js3GiaaQJ-zqyuledzZP-PEOV-y_Fx87-U6HVu4nh8kfwPzfPU50yEV5oscb20ptwMGR5EEoAtE8dfAlwCVejJtP779upzfAqn_ID5IQJ2F9Nw218‘)");
driver.findElement(By.name("recaptcha_response_field")).sendKeys("23129555894");
driver.findElement(By.name("Button1")).click();
Note: setAttribute plays a major role here.
Look at this example for reference..
driver.get("http://www.google.com/recaptcha/learnmore");
driver.switchTo().frame(0); //calling iframe with no id
javascriptExecutor js = (JavascriptExecutor) driver;
//Setting the captcha values
js.executeScript("document.getElementsByName(‘recaptcha_challenge_field‘)[0].setAttribute(‘value‘,‘03AHJ_Vuv4tV3FrmUHbImL9JPkWJNqs1KDbFdKfG1jhqa2Uhl4U1vzLxXtZMMkZoAHuVCXA1js3GiaaQJ-zqyuledzZP-PEOV-y_Fx87-U6HVu4nh8kfwPzfPU50yEV5oscb20ptwMGR5EEoAtE8dfAlwCVejJtP779upzfAqn_ID5IQJ2F9Nw218‘)");
driver.findElement(By.name("recaptcha_response_field")).sendKeys("23129555894");
driver.findElement(By.name("Button1")).click();
Note: setAttribute plays a major role here.
Hi Prasanth,
ReplyIs there anyway to type captcha text without typing 23129555894 other than OCR.
Hi
ReplyI do the same what you write but it shows incorrect Captcha.
from where you got this value or why we are entering this 23129555894 ?
Reply