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.
How to automate this captcha
ReplyDeletehttp://register.rediff.com/register/register.php?FormName=user_details
i don't think , that this could be automated because its an image and text value is not anywhere there in the html code so we can't get the text value of this.
DeleteI already given example of similar type, you can refer above in the post. Thanks.!!
Hi Sanjay, nice blog very informative and helpful. Thanks a lot .
ReplyDeleteIn this captcha example 2 looks like there is typo "Such kind of captcha can be automated." it should be cannot be automated
Thanks Hari for pointing out, i have changed now. Thanks!!
DeleteHi All,
DeleteI want to automate web Application, But it contains captcha.
The Xpath is:
.
can i automate the captcha by using any one of the above attributes.
Please help me.
I believe this is not working as expected buddy. Could you please recheck. I tried the exact program but not giving me the captcha value.
ReplyDeleteHi Sanjay, nice blog..Thank you very much..
ReplyDeleteCaptcha is an image file..how can u convert it into text..and also it is dyamic..it will change the value every time..
as mentioned in blog, if value of captcha is present in dom then only you can automate it. Or if you can get the value of captcha from your dev then you can automate else not.
Deleteim using win7 32-bit, jst now i installed jdk, Eclipse(Mars), and added selenium webdriver jar file in build path to a new proj...
ReplyDeletebut when i running a program..it is jst opening FF browser., not going to the output webpage...show me a solution to it..
downgrade your firefox version to 45.0.
Deletehttps://ftp.mozilla.org/pub/firefox/releases/45.0/mac/en-US/
There is some issue with the firefox version 47 and 48.
Thank U Sanjay..I will try
Delete