Ask a Question

Close a pop-up window in Chrome during a test

SOLVED
AmulyaT
Visitor

Close a pop-up window in Chrome during a test

Hi, 

I am running a test and I am getting the security alert pop-up window. 

I am getting this window only on production site and not when recording the test locally. 

I am new to TestComplete and not sure how to close this window during the test. Please help.

I have seen in other threads that we can use If Object, but since I am not getting this popup when recording the test, I cannot drag and drop for the object.

Thanks.

2 REPLIES 2
Marsha_R
Community Hero

You could run TC on your production environment to just record a test that will click the button you need.  That will give you the objects and then you can use them in your test however you like.


Marsha_R
[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
jr348
Contributor

We use this to close unexpected windows "Leave This Page?"

 

The first one is is run as an event handler from event OnWebBeforeNavigate.

 

 

function Test_Complete_Test_Run_Events_OnWebBeforeNavigate(Sender, WebBrowser, URL)
{
        // Check for the presence of the "Leave This Page?" popup
        
        
        Close_Leave_Site_popup();
}


function Close_Leave_Site_popup()
{
        var Max_Wait_Time_ms = 500;

               // Check for Edge unexpected window...
        if(Aliases.browser.Application_Main_Page.Browser_Leave_Site_popup.Leave_button.WaitProperty("Exists", true, Max_Wait_Time_ms) == true)
        {
                Aliases.browser.Application_Main_Page.Browser_Leave_Site_popup.Leave_button.Click();
                Log.Message("MS Edge: UNEXPECTED WINDOW closed");
        }
        
        // Check for IE unexpected window...
        if(Aliases.browser_IE.Application_Main_Page.Browser_Confirm_popup.Leave_This_Page_button.WaitProperty("Exists", true, Max_Wait_Time_ms) == true)
        {
                Aliases.browser_IE.Application_Main_Page.Browser_Confirm_popup.Leave_This_Page_button.Click();
                Log.Message("IE: UNEXPECTED WINDOW closed");
        }

}

 

And as @AmulyaT  said you can obtain the mapping by recording or spying the window and mapping it manually or using a suitable template.

 

We also get Java popups which we clear using a simple "close" or  refreshing the page.

cancel
Showing results for 
Search instead for 
Did you mean: