Friday 30 March 2012

Selenium IDE and CAPTCHA


Selenium can only be used to test a web app protected by CAPTCHA if a human involved for the test. So, if you are automating registration form of any site that includes a CAPTCHA, you will require human interaction during the specific section that requires a CAPTCHA response.

There are two ways in which you can automate CAPCHA
1.By break command
2.By input-box

Suppose after command 3, there is CAPTCHA

1.By break command

Command 1
Command 2
Command 3
4th command will be
Break
Enter CAPTCHA manually and resume execution of test
continue with your next commands

2.By input-box
Command 1
Command 2
Command 3
4th command will be
storeEval | prompt(“Enter value for captcha”); |variable
type | locator of CAPTCHA field | ${variable}
continue with your next commands



14 comments:

  1. very helpful :) thanks

    ReplyDelete
  2. How you will do it in selenium Webdriver?

    ReplyDelete
  3. @venkatesh - you can refer http://stackoverflow.com/questions/8530875/get-around-capcha-in-selenium

    ReplyDelete
  4. Hi, I am new to selenium and i had no idea of selenium webdriver.
    Can u please tell me how to do this in Selenium-RC?

    ReplyDelete
  5. For selenium RC, please refer below code
    String variable = selenium.getEval("prompt(\"Enter Value For Catpcha\")");
    selenium.type("locator of CAPTCHA field", variable);

    ReplyDelete
  6. Kudos! This is very helpful. :)

    ReplyDelete
  7. How to handle captch code using selenium webdriver

    ReplyDelete
    Replies
    1. I have mentioned one URL above -
      http://stackoverflow.com/questions/8530875/get-around-capcha-in-selenium
      It will may help you :)

      Delete
  8. I used the the below :

    StorEval prompt("Enter value for captcha") captcha
    type id=captcha ${captcha}

    It captures the captcha value however at the time of submitting the form it gives an error the entered number for captcha is incorrect.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Hi,

    Question 1:
    When using 'input-box' command in IDE 2.0.0, received error with captcha despite entering correct captcha. Example: 'frammix fame'. Note the blank space in the above example. Any solution for this?

    Question 2:
    When using 'break' command in IDE 2.0.0, the test paused at the command 'comment'. After entering captcha value, clicking 'Pause/Resume' icon in the toolbar displayed error - unknown command: 'comment'. How should I make it work?

    Thanks in advance for your help.

    ReplyDelete
  11. Both cases working fine for me.
    I'm also using IDE 2.0.0

    ReplyDelete
  12. I Used Input box but i got error "[error] Element id=id('capchareset') not found"

    ReplyDelete