Showing posts with label Captcha. Show all posts
Showing posts with label Captcha. Show all posts

Thursday, May 29, 2014

Captcha which could be automated.


1- Captcha which could be automated-

This is the example from-  http://www.indianrail.gov.in/pnr_Enq.html 




import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class CaptchaAutomated {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get("http://www.indianrail.gov.in/pnr_Enq.html");
        String captchaValue = driver.findElement(By.xpath("//span[@id='txtCaptchaDiv']")).getText();  //this will read the captcha
        System.out.println(captchaValue);
        driver.findElement(By.xpath("//input[@id='txtInput']")).sendKeys(captchaValue);
    }
}

Output-  This program will read the captcha and will enter the value of captcha in the Enter Captcha box.




2- Captcha which could not be automated-

This is an example from - https://signup.live.com/signup.aspx
Such kind of captcha can not be automated.