Automating(Breaking) captcha using Selenium Webdriver
Usually most of the companies either use their own captchas or one of the third party captchas
(Google, jQuery plugins) in the user registration page of their sites .So these pages can't be
automated fully.
automated fully.
Infact Captcha itself is implemented to prevent automation. As per official captcha site
A CAPTCHA is a program that protects websites against bots by generating and grading tests that humans can pass but
current computer programs cannot.
Captchas are not brakeable but there are some third party captchas that can be breakable and one of
the example for it is "jQuery Real Person" captcha . Here is the documentation :)
A CAPTCHA is a program that protects websites against bots by generating and grading tests that humans can pass but
current computer programs cannot.
Captchas are not brakeable but there are some third party captchas that can be breakable and one of
the example for it is "jQuery Real Person" captcha . Here is the documentation :)
Here is the sample code to brake the "jQuery Real Person" Captcha using Selenium WebDriver.
import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; public class captchaAutomtion { WebDriver driver; @BeforeTest public void start(){ driver = new FirefoxDriver(); } @Test public void Test(){ //Loading jQuery Real Person Captcha demonstration page driver.get("http://keith-wood.name/realPerson.html"); JavascriptExecutor js = (JavascriptExecutor) driver; //Setting the captcha values js.executeScript("document.getElementsByName('defaultRealHash')[0]
.setAttribute('value', '-897204064')"); driver.findElement(By.name("defaultReal")).sendKeys("QNXCUL"); //Submit the form driver.findElement(By.xpath(".//*[@id='default']/form/p[2]/input")).
.submit(); } }