Wednesday, 11 September 2013

Handling Captcha | Webdriver

Make use of the 'input' tag with type 'hidden' in-order to handle Captcha.

Look at this example for reference..

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')");

Note: setAttribute plays a major role here.


  1. Hi Prasanth,

    Is there anyway to type captcha text without typing 23129555894 other than OCR.

  2. Hi
    I do the same what you write but it shows incorrect Captcha.

  3. from where you got this value or why we are entering this 23129555894 ?

  4. Thanks for the great information in your blog Selenium Training in Chennai

  5. Is it necessary to apply getElementsByName('')

    Because I dont have any name in the element.
    will it work without name attribute ?

  6. I recently came across your blog and have been reading along. I thought I would leave my first comment.
    python Training institute in Pune
    python Training institute in Chennai
    python Training institute in Bangalore

  7. I read this post two times, I like it so much, please try to keep posting & Let me introduce other material that may be good for our community.
    Best Devops online Training
    Online DevOps Certification Course - Gangboard

  8. Well done! Pleasant post! This truly helps me to discover the solutions for my inquiry. Trusting, that you will keep posting articles having heaps of valuable data. You're the best! 
    Data Science course in Chennai
    Data science course in bangalore
    Data science course in pune
    Data science online course
    Data Science Interview questions and answers
    Data Science Tutorial
    Data science course in bangalore