Handling JavaScript Dialogs

With Alerts, you only need to define how the alert should be handled. Your options for alert handling are: DialogButton.OK or DialogButton.CLOSE (close the window using ).

 

C#

// Add an alert dialog to monitor
Manager.DialogMonitor.AddDialog(new AlertDialog(ActiveBrowser, DialogButton.OK));
  
// Given that there were not dialog attribute set, the manager will not start the monitoring.
// You need to invoke the monitoring
Manager.DialogMonitor.Start();
  
// Invoke an alert dialog
Actions.InvokeScript("InvokeAlert()");
  
// The dialog will now be automatically handled transparently in the background without any help from the test code.

 

Visual Basic

' Add an alert dialog to monitor
Manager.DialogMonitor.AddDialog(New AlertDialog(ActiveBrowser, DialogButton.OK))
  
' Given that there were not dialog attribute set, the manager will not start the monitoring.
' You need to invoke the monitoring
Manager.DialogMonitor.Start()
  
' Invoke an alert dialog
Actions.InvokeScript("InvokeAlert()")
  
' The dialog will now be automatically handled transparently in the background without any help from the test code.