码迷,mamicode.com
首页 > Web开发 > 详细

Handling Captcha | Webdriver

时间:2016-03-16 07:07:57      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:

http://seleniumworks.blogspot.kr/2013/09/handling-captcha-webdriver.html

 

 

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.
 

3 comments:

  1. 技术分享

    Hi Prasanth,

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

    Reply
     
     
  2. 技术分享

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

    Reply
     
     
  3. 技术分享

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

    Reply

Handling Captcha | Webdriver

标签:

原文地址:http://www.cnblogs.com/donaldlee2008/p/5281960.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!