Ask a Question

Handle chrome javascript alerts

TCYKPB
Occasional Contributor

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:

TCYKPB_0-1628180254079.png

 

I am using Javascript as my scripting language for TestComplete.

 

Thanks.

12 REPLIES 12
mattb
Staff

Re: Handle chrome javascript alerts

Hi,

There are some Chrome command line arguments that helps make the browser more automation friendly. See 2nd half of this page: https://support.smartbear.com/testcomplete/docs/app-testing/web/general/preparing-browsers/chrome.ht... 

TCYKPB
Occasional Contributor

Re: Handle chrome javascript alerts

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.

mattb
Staff

Re: Handle chrome javascript alerts

Hi,

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. 

TCYKPB
Occasional Contributor

Re: Handle chrome javascript alerts

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.

HKosova
Moderator

Re: Handle chrome javascript alerts

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. ⬇️⬇️⬇️
TCYKPB
Occasional Contributor

Re: Handle chrome javascript alerts

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."

HKosova
Moderator

Re: Handle chrome javascript alerts

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. ⬇️⬇️⬇️
AlexKaras
Community Hero

Re: Handle chrome javascript alerts

Hi,

 

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

Might be something related to https://community.smartbear.com/t5/TestComplete-Functional-Web/Login-object-cannot-be-found-anymore/...

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
TCYKPB
Occasional Contributor

Re: Handle chrome javascript alerts

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.

cancel
Showing results for 
Search instead for 
Did you mean: