Confirm Object

Applies to TestComplete 15.64, last modified on June 12, 2024


The Confirm test object corresponds to a web browser’s message box with two buttons to select from. Examples include:

  • Confirmation boxes displayed by the JavaScript confirm function.

  • Message boxes displayed by the onbeforeunload event handler when the user leaves the page.

  • Message boxes asking whether to resubmit forms when the user reloads the web page.

You can get the message text using the Message property and close the message box by simulating a click on the OK or Cancel button.

For more information on automating these message boxes, see Handle JavaScript Popups and Browser Dialogs.


  • A license for TestComplete Web module.

  • The Web Testing plugin. This plugin is installed and enabled automatically. The plugin implements the Confirm test object, as well as the web testing functionality.



The following example demonstrates how to click the OK button in a confirmation box:

JavaScript, JScript

function Confirm_Demo()
  var url = "";

  var page = Sys.Browser().Page("*smartbear*/samples/testcomplete*/dialogs/");
  var link = page.FindChild("contentText", "Show Confirm", 10);

  Log.Message("Message text: " + page.Confirm.Message);



Sub Confirm_Demo()
  url = ""

  Set page = Sys.Browser().Page("*smartbear*/samples/testcomplete*/dialogs/")
  Set link = page.FindChild("contentText", "Show Confirm", 10)

  Log.Message("Message text: " & page.Confirm.Message)
End Sub


procedure Confirm_Demo();
var url, page, link;
  url := '';

  page := Sys.Browser().Page('*smartbear*/samples/testcomplete*/dialogs/');
  link := page.FindChild('contentText', 'Show Confirm', 10);

  Log.Message('Message text: ' + page.Confirm.Message);

C++Script, C#Script

function Confirm_Demo()
  var url = "";

  var page = Sys["Browser"]()["Page"]("*smartbear*/samples/testcomplete*/dialogs/");
  var link = page["FindChild"]("contentText", "Show Confirm", 10);

  Log["Message"]("Message text: " + page["Confirm"]["Message"]);

See Also

Testing Web Applications
Handle JavaScript Popups and Browser Dialogs
Alert Object
Login Object

Highlight search results