Codeception
Codeception copied to clipboard
how to write functional test for form having captcha validation?
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
-vvvmode for more details.
There was 1 failure:
- 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:
- $I->see("Thank you for getting in touch!") at ../../../../frontend/tests/functional/ContactCest.php:59
- $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
- $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
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.
not a bug