The PayPal button doesn’t render in Playwright’s headless mode because PayPal’s bot detection identifies the headless browser as a potential threat, blocking the widget. This happens due to differences like the “HeadlessChrome” user agent or other automation signals, unlike headed mode where it works fine.
Workarounds:
Use the playwright-stealth plugin to hide automation signs.
Set a custom user agent to mimic a regular Chrome browser.
Try Chromium’s new headless mode with the chrome channel.
Run headed mode with Xvfb in CI to simulate a display.
Start with playwright-stealth, then try the user agent or new headless mode. Use Xvfb as a fallback for CI. Verify with screenshots, as PayPal’s detection may still interfere.