How to handle online captchas in WebDriver.

2,733 views
Skip to first unread message

Yogesh Tyagi

unread,
Jan 5, 2014, 2:27:36 AM1/5/14
to seleniu...@googlegroups.com
Hi All,

How to handle online captchas in WebDriver.

Like: 15 + 5 =

A website has a text box and this text box will accept the input of sum of two numbers. How we capture these two number like 15 and 5. And any number can be come at this location.


Please help me out.


Regards,
Yogesh Kumar

Vaibhav P

unread,
Jan 5, 2014, 2:51:09 AM1/5/14
to seleniu...@googlegroups.com
Ironically, You are trying to defy the main purpose Captcha serves for - To avoid robots.

If "15+5" is Captcha image and subject to change after each refresh, It is certainly not possible to predict and automate this scenario using webdriver.

But if "15+5" is a text identifyable via proper DOM structure, you can find a workaround to deal with. Of course, It isn't a Captcha in that case. 

--
Vaibhav


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/2018f17e-010d-43a1-b19a-3804db7f0662%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Yogesh Tyagi

unread,
Jan 5, 2014, 8:44:40 AM1/5/14
to seleniu...@googlegroups.com

Hi Vaibhav,

This is a text instead of image, and after each refresh this text is changed.

Regards,

Krishnan Mahadevan

unread,
Jan 6, 2014, 12:10:26 AM1/6/14
to Selenium Users
Is it possible for you to grab hold of this text via the DOM ? If yes, then you can use that, else you would need to work with your dev folks to give you a by pass value which can be used in your test environments.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


Christian LeMoussel

unread,
Jan 6, 2014, 2:42:31 AM1/6/14
to seleniu...@googlegroups.com
If is it possible to grab hold of this text via DOM, you can resolve it by JS or C# code.




niharika varshney

unread,
Jan 6, 2014, 2:44:21 AM1/6/14
to seleniu...@googlegroups.com
Then your dev is implementing captcha all wrong.  I would log this as a bug.

Regards,
NV


On Mon, Jan 6, 2014 at 1:12 PM, Christian LeMoussel <cnh...@gmail.com> wrote:
If is it possible to grab hold of this text via DOM, you can resolve it by JS or C# code.




--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

Yogesh Tyagi

unread,
Jan 6, 2014, 6:46:13 AM1/6/14
to seleniu...@googlegroups.com

Hi Niharika,

How it is wrong? And how you would say that it is a bug, text will be change always and it will be input for next text box.

Regards,
Yogesh

Shawn McCarthy

unread,
Jan 6, 2014, 9:12:47 AM1/6/14
to seleniu...@googlegroups.com
Because the whole point of a captcha is to STOP people from automating it. If you can automate the captcha, than it is implemented incorrectly.

niharika varshney

unread,
Jan 6, 2014, 9:47:22 AM1/6/14
to seleniu...@googlegroups.com
If you can capture the captcha text, then you can as well write the logic to get the answer.  In your case if you can capture 15 and 5, you can calculate it and put in the answer.  And +1 to Shawn.


David Lai

unread,
Jan 6, 2014, 12:30:48 PM1/6/14
to seleniu...@googlegroups.com
Gotta just push the devs to add a work around or a way to disable it in the test environment.

It's not only going to be a problem with automation, it'll stop you from performing:
- security scans, 
- load testing, 
- transactional uptime monitoring

Alka Arya

unread,
Jan 13, 2014, 2:16:05 AM1/13/14
to seleniu...@googlegroups.com

Christian LeMoussel

unread,
Jan 13, 2014, 3:39:11 AM1/13/14
to seleniu...@googlegroups.com
When refresh, I think it is possible to display same text with cookie ;)


2014/1/13 Alka Arya <arya...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/UHqW3V4AdTo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

Ripon Al Wasim

unread,
Jan 13, 2014, 3:43:24 AM1/13/14
to seleniu...@googlegroups.com
If it's not image it's easy to automate. Identify the location (by id, name, or xpath) and getText(). So u will get the numbers and sum it.

br,
Ripon


--

vishnu

unread,
Jan 13, 2014, 5:29:07 AM1/13/14
to seleniu...@googlegroups.com
For ideal implementation of Captcha, there shouldn't be any automation feasible. So there should be an easter egg to handle this for automation sake.

Following are different approaches that may be employed to disable Captcha presence or Captcha validation
1. Pass a specific querystring and value combination in the URL
2. Configure in AppSettings in Web.config to turn the feature on or off and trun it off in test envt
3. Sniff client IP address and disable feature only for requests from intranet/test environment ip range
4. Enter specific "predefined" captcha code irrespective of what is rendered

There could be few more, the idea is to insert an easter egg into the code.

Thanks,
Vishnu

Ripon Al Wasim

unread,
Jan 13, 2014, 5:30:50 AM1/13/14
to seleniu...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages