Skip to content

Browser Check Failed in Playwright Automated Tests #59

@iranimij

Description

@iranimij

Description

When running automated tests with Playwright, the Friendly Captcha widget fails with the error message:

Verifizierung fehlgeschlagen
Browser check failed, try a different browser

This occurs consistently across all Playwright browser contexts (Chromium, Firefox, and WebKit), making it impossible to run automated end-to-end tests for forms protected by Friendly Captcha.

Environment

  • Magento Version: 2.4.8-p3
  • IMI_FriendlyCaptcha Version: 3.1.1
  • Playwright Version: 1.56.1
  • PHP Version: 8.3
  • Test Environment: Warden Docker environment

Steps to Reproduce

  1. Install and configure IMI_FriendlyCaptcha module
  2. Enable Friendly Captcha on any form (e.g., contact form, login)
  3. Find the Playwright robot IP address and add it to the white list field imi_friendly_captcha/general/trusted_ips
  4. Set up Playwright test to interact with the protected form
  5. Run test with any Playwright browser (chromium/firefox/webkit)
  6. Observe the "Browser check failed" error

Current Configuration Attempts

I have already tried the following configurations without success:

  1. Added Playwright Robot IP to Trusted IPs

    • Configuration: Stores > Configuration > Security > Friendly Captcha > Trusted IPs
    • Path: imi_friendly_captcha/general/trusted_ips
    • Result: Still failing
  2. Tested Multiple Browsers

    • Chromium (Playwright default)
    • Firefox
    • WebKit
    • Result: All browsers fail with the same error

Expected Behavior

The Friendly Captcha widget should either:

  1. Allow whitelisting of specific IPs/user agents for automated testing purposes
  2. Provide a test mode or bypass mechanism for CI/CD environments
  3. Work seamlessly with Playwright's browser automation

Actual Behavior

The widget detects Playwright's automated browser context and blocks all attempts with "Browser check failed" error, making automated testing impossible.

Possible Root Cause

Friendly Captcha's browser verification likely detects automation signals present in Playwright browsers, such as:

  • navigator.webdriver property
  • Missing browser-specific features
  • Automated context indicators
  • Timing patterns typical of automation

Suggested Solutions

  1. Test Mode Configuration: Add a configuration option to disable browser checks in test/development environments
  2. Enhanced IP Whitelist: Make the trusted IPs feature bypass browser checks completely
  3. Playwright Detection Handling: Add specific support for Playwright user agents when coming from trusted IPs
  4. Environment Variable: Support a Magento configuration or environment variable to disable strict browser checks

Workaround Needed

For CI/CD pipelines and automated testing, we need a reliable way to bypass the Friendly Captcha validation. Current options would be:

  • Conditionally disable Friendly Captcha in test environments
  • Mock the Friendly Captcha widget in tests
  • Use a different validation approach for automated tests

However, none of these allow us to properly test the actual user flow with Friendly Captcha enabled.

The ability to test forms with Friendly Captcha enabled is critical for ensuring the complete user experience works as expected in production.

Questions

  1. Is there an official recommended approach for handling Friendly Captcha in automated tests?
  2. Can the trusted IPs feature be enhanced to completely bypass browser checks?
  3. Are there any hidden configuration options or environment variables that could help?

Would appreciate any guidance or consideration for a test-friendly mode in future releases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions