Fix browser monitor failing due to a warning popup blocking the page - #237
Conversation
… not just buttons
There was a problem hiding this comment.
🟡 Not ready to approve
The Mode A interstitial dismissal step is still configured to fail when the popup is absent, which conflicts with the PR’s stated goal of safely continuing when no popup is present.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR updates the DataDog browser synthetic test generator to be resilient to interstitial “Continue”/consent overlays and to avoid false matches against hidden/duplicate DOM text by preferring semantic headings before falling back to a broader text match.
Changes:
- Enhanced Browser_Query parsing to optionally detect and translate a scripted “dismiss interstitial then assert” flow (DISMISS_XPATH + click + second wait).
- Added a Mode B “best effort” interstitial dismissal step for Validation_Text-only monitors, and changed Mode B validation to use
assertElementPresentwith ordered XPath candidates (heading-first, then anywhere). - Tightened CONFIG parsing to avoid misreading
DISMISS_XPATHasXPATHvia a safer regex.
File summaries
| File | Description |
|---|---|
| monitoring/scripts/datadog/monitors/synthetics/set_browser_monitor.py | Adds interstitial-dismissal support and improves locator strategy to reduce false synthetic failures. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Low
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| # | ||
| # Rather than excluding <header>/<nav>/<footer> outright (which would | ||
| # also block legitimate matches that really do live there), this gives | ||
| # DataDog two ordered candidates in "values": a heading (h1-h6) match |
| "isCritical": True, | ||
|
|
||
| "params": { | ||
|
|
||
| "element": { | ||
|
|
||
| "userLocator": { | ||
|
|
||
| "failTestOnCannotLocate": True, | ||
|
|
||
| "values": [ | ||
|
|
||
| {"type": "xpath", "value": parsed["dismiss_xpath"]}, | ||
|
|
||
| ], | ||
|
|
||
| }, | ||
|
|
||
| }, | ||
|
|
||
| }, |
This PR fixes the synthetic check, which was repeatedly failing even though the website was functioning correctly.
The failure was caused by a government warning popup ("An official website of the United States government... Continue") that appeared before the actual page content. The popup prevented the check from validating the visible page, resulting in repeated "Element located but it's invisible" errors.
Additionally, the check was matching hidden duplicate text in the page header instead of the actual visible page heading.
Root Cause
A government warning popup blocked access to the page content.
The synthetic check attempted to validate the page before dismissing the popup.
The initial popup dismissal logic only searched for "Continue" inside elements, while the site rendered it using a different element.
After dismissing the popup, the check still failed because it found a hidden copy of "Population" in the site's logo/header instead of the visible page heading.
Changes Made
Added an automatic popup dismissal step before page validation.
Updated the locator to search for the "Continue" text regardless of element type, making it compatible with the site's implementation.
Configured the popup dismissal step to safely continue if no popup is present, ensuring the check works across pages that don't display the warning.
Updated the validation logic to:
Impact