Ask a Question

Handle chrome javascript alerts


Handle chrome javascript alerts

Hello, does anyone know how to detect and close these alerts that might appear in Chrome when leaving from a website with unsaved changes. Example:



I am using Javascript as my scripting language for TestComplete.





There are some Chrome command line arguments that helps make the browser more automation friendly. See 2nd half of this page: 

Hello @mattb, I couldn't find any reference to how to handle alerts on the link you provided.

I just need a way to either confirm or decline the alert pop up. In selenium there is somehting like switchTo.Alert.Confirm() or switchTo.Alert.Decline(). I need to interact with these type of alerts in TestComplete and still I couldn't find anything in the documentation.


We could just interact with the pop up, I would recommend just using a single action at first to see what it is identified with. When you interact with it via keyword test, it will automatically map the object (With Se or with Properties, depending on how its identified)

Those command line arguments I passed before, are browser specific arguments, that help force the browser to be more automation friendly. 

Thanks @mattb, unfortunately the object spy does not work to detect the alert in my chrome browser, nor there is documentation about this basic feature that is present in all browsers.

I appreciate the recommendations about the command line arguments, but in a real world scenario the users do not open their browsers with command line arguments, so it is highly NOT recommended to test the applications in a way the user would not use them.

SmartBear Alumni (Retired)

Hi @TCYKPB, see if this helps:

Handle JavaScript Popups and Browser Dialogs with TestComplete

Helen Kosova
SmartBear Documentation Team Lead
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

Hi @HKosova , I already tried with [...].Alert.Button("OK").Click(); as in the example, and with any other form I could think of, and all I got was an error message saying "Unable to find object Alert."

SmartBear Alumni (Retired)

Try Confirm instead of Alert.

Helen Kosova
SmartBear Documentation Team Lead
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Champion Level 3



Can this window be identified using Object Spy / Object Browser?

Might be something related to


  /Alex [Community Champion]
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.

Tried with the "Confirm" object, also getting "Unable to find the object Confirm".

Object spy does not work either, when I hover over the alert, TestComplete just freezes and stops working.

Showing results for 
Search instead for 
Did you mean: