MTCaptcha supports automated browser UI/UX testing via tools like Selenium, without having to disable the captcha plugin.
There are two methods to enable automation test scripts to consistently solve the captcha:
Method 1:
<script>
mtcaptcha.enableTestMode(“<TestKey>”);
</script>
Method 2:
<script>
var mtcaptchaConfig = {
“sitekey”: “<SiteKey>”,
“enableTestMode” : “<TestKey>”
};
...
</script>
Where Can I Find The Testkey?
The TestKey for each site can be found in the Admin Portal along with the SiteKey and PrivateKey. Usually with the prefix ‘MTPrivQA-’. Note: The TestKey should be kept secret.
The captcha will create a VerifiedToken once solved using a TestKey, the same as if a user solved the captcha manually.
To check if a VerifiedToken is the result of using the TestKey, the decoded token information (JSON) will have the corresponding TokenInfo.code of 301 and codeDesc ‘valid-test:captcha-solved-via-testkey’. CheckToken API Response:
{
"success": true,
"tokeninfo": {
"code": 301,
"codeDesc": "valid-test:captcha-solved-via-testkey",
...
}
}
See our Developers Guide - Validate Token - for more information on VerifiedToken, CheckToken API, and TokenInfo Codes
NOTE:
The purpose of this feature is to support automated unit tests for user interface and interactions. It is not intended to support long running load or performance tests. The captcha may temporarily block test server IP(s) if loaded for long periods of time.
REFERENCES
Stack Overflow: How to call a JavaScript function from within Selenium
Stack Overflow: Selenium : Call javascript function on page.