Codeception icon indicating copy to clipboard operation
Codeception copied to clipboard

how to write functional test for form having captcha validation?

Open loks15 opened this issue 8 years ago • 2 comments

What are you trying to achieve?

trying to write a functional test for form having captcha validation.

What do you get instead?

verification code is invalid

Provide console output if related. Use -vvv mode for more details.

There was 1 failure:


  1. ContactCest: Check contact submit correct data Test ../../../../frontend/tests/functional/ContactCest.php:checkContactSubmitCorrectData Step See "Thank you for getting in touch!" Fail Failed asserting that on page /index-test.php/form/contact-us --> --> contains "Thank you for getting in touch!".

Scenario Steps:

  1. $I->see("Thank you for getting in touch!") at ../../../../frontend/tests/functional/ContactCest.php:59
  2. $I->submitForm("#frm-dynamic",{"GenericForm[name]":"tester","GenericForm[email]":"[email protected]","GenericForm[subject]":"test subject","GenericForm[message]":"test content","GenericForm[mobile_...}) at ../../../../frontend/tests/functional/ContactCest.php:52
  3. $I->amOnPage(["form/contact-us"]) at ../../../../frontend/tests/functional/ContactCest.php:17
# paste output here

Provide test source code if related

// paste test

Details

  • Codeception version:
  • PHP Version:
  • Operating System:
  • Installation type: Phar || Composer
  • List of installed packages (composer show)
  • Suite configuration:
# paste suite config here

loks15 avatar Oct 04 '18 10:10 loks15

It depends on the test framework and captcha you're using. If you use an external captcha like reCaptcha from google they have an API key for testing, which will always accept the users' response. If you use an internal widget you should somehow either force its value, or read its value from the application state; this depends on which framework you use.

SamMousa avatar Oct 04 '18 10:10 SamMousa

not a bug

Naktibalda avatar Jan 05 '21 17:01 Naktibalda