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

Relic Solutions: Screen shot not taken due to alert box

synthetics-script

#1

My screenshot wasn’t taken. What gives?!

Sometimes an alert box will be open, and that blocks the screen shot from being taken. You’ll see in the script log UnexpectedAlertOpenError: unexpected alert open.

This is a known limitation of WebDriver where it cannot capture a screenshot with an Alert box open.

To avoid this, you can use the following custom function to see if an alert is present and accept it.

function isAlertPresent() { 
  $browser.switchTo().alert().then(function(diag){
     diag.accept()
    return true
  }, function() {
    return false
  })
}

If this does not suit, you can use alertIsPresent() as described in the scripted browser reference.