Skip to content

Fix browser monitor failing due to a warning popup blocking the page - #237

Merged
cawohnjing merged 5 commits into
mainfrom
fix/browser-monitor-check
Jul 30, 2026
Merged

Fix browser monitor failing due to a warning popup blocking the page#237
cawohnjing merged 5 commits into
mainfrom
fix/browser-monitor-check

Conversation

@cawohnjing

Copy link
Copy Markdown
Collaborator

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:

  • First verify the text in the page's primary visible heading.
  • Fall back to searching the rest of the page only if necessary.
  • Prevented hidden or duplicate elements (such as logo/header text) from causing false matches.

Impact

  • Eliminates false failures caused by the government warning popup.
  • Improves reliability by validating visible user-facing content instead of hidden DOM elements.
  • Makes the synthetic check more resilient and reusable for pages that may display similar warning overlays in the future.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 assertElementPresent with ordered XPath candidates (heading-first, then anywhere).
  • Tightened CONFIG parsing to avoid misreading DISMISS_XPATH as XPATH via 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
Comment on lines +495 to 515
"isCritical": True,

"params": {

"element": {

"userLocator": {

"failTestOnCannotLocate": True,

"values": [

{"type": "xpath", "value": parsed["dismiss_xpath"]},

],

},

},

},
@cawohnjing
cawohnjing merged commit 1b03012 into main Jul 30, 2026
7 checks passed
@michael-fleming-nih
michael-fleming-nih deleted the fix/browser-monitor-check branch July 30, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants