Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

Interacting with alert boxes



Here’s an example of using NR Synthetics to interact with and close an alert box.

  return $browser.switchTo().frame(0);
  return $browser.findElement({xpath: '/html/body/button'}).click();

A few important notes:

  • Because of how the w3schools site works, we must first switch to the iframe holding the element we are interesting in clicking on (that’s what the $browser.switchTo().frame(0) is doing)
  • $browser.switchTo().alert() switches the viewport to the alert box and, in this case, all we do is accept it

Related selenium-webdriver documentation

Problems with Pop up Dialog