Is any way to get captcha value and store it in a variable?
I am Using Selenium RC in C# My application has 3 Captha image in Different registration pages. i have a Huge script i will run it on night hours(开发者_开发问答when i am off). Hence i feel it will be better if i can capture the last displaying captcha image value and store it in to a variable so that i can input on the relevant field. Is it Possible ?
A Captcha cannot be automated that easily. That is why they were invented!!
Alas... You can use code hackers and Image Recognition patterns and scripts. It is called OCR. http://en.wikipedia.org/wiki/Optical_character_recognition
I will not write more about this as i wont encourage others for hacking ideas. But... First: Google is your friend. Second: In my testing environment we used a captcha with a static value. And then before it went live we removed set it again for the algorithm.
Gergely.
Have a hidden field (with a non-obvious name) that contains a strongly encrypted copy of the text used in the captcha then on your selenium test system decode it using the private key?
For testing purposes you will need to send the captcha value in a machine readable manner, by sending it as an additional field. You would then need to remove the field after the tests are done.
Make use of the 'input' tag with type 'hidden' in-order to handle Captcha.
JavascriptExecutor js = (JavascriptExecutor) driver;
//Set the captcha values using setAttribute
js.executeScript("document.getElementsByName('xxxx')[0].setAttribute('value', 'xxxx')");
driver.findElement(By.name("xxxx")).sendKeys("xxxx");
精彩评论