Popup closing

226 views
Skip to first unread message

Daniel Bichuete

unread,
Jan 21, 2011, 7:56:20 AM1/21/11
to Internet Explorer Macros with Twebst Automation Studio
Hi Adrian,

Just opened this new post so we can separate discussions. I have been
trying to automate some site that popup automation is needed. Since I
use Twebst Library, isnt it supposed to support it ?
I tried closing using IBrowser.ClosePopup("","OK") and unfortunatly I
wasn't able.

Best regards,

Daniel Bichuete

Daniel Bichuete

unread,
Jan 21, 2011, 8:23:50 AM1/21/11
to Internet Explorer Macros with Twebst Automation Studio
Hey Adrian,

Just figure out the way you are closing popup. So for ClosePopup to
work we need to use hardware events not HTML ones on ICore. Great !

Have a nice day !

Daniel Bichuete

codecentrix

unread,
Jan 21, 2011, 8:44:12 AM1/21/11
to twebst-autom...@googlegroups.com
If the pop-up is generated by a click on a button or anchor for instance, the click action is blocking until the pop-up is closed so there's no chance for closePop-up method to close the pop-up.
 
For this you can either use hardware events that will generate windows mouse events or you can set core.asyncHtmlEvents to true so the click is not blocking.
 
Regards,
Adrian.
 

Shawn Ramirtha

unread,
Jul 26, 2012, 2:05:30 PM7/26/12
to twebst-autom...@googlegroups.com

I have tried the following statements and all of them give me a "Timeout in ClosePopup Method Call".

browser.ClosePopup("*", "Leave this page");

browser.ClosePopup("", "Leave this page");

browser.ClosePopup("Are you sure you want to leve this page?","Leave this page");

 

I have set core.asyncHtmlEvents = true; and core.asynHtmlEvent = false; I've also tried it with useHardwareInputEvents set to true and set to false. Any help would be greatly appreciated.

Thanks,
Shawn

codecentrix

unread,
Jul 27, 2012, 4:18:22 AM7/27/12
to twebst-autom...@googlegroups.com
Hi

That's an interesting scenario!
closePopup can close modal dialog boxes generated by window.alert and window.confirm.

From what I see in your attached picture I'm not sure that your dialog box is generated by window.alert or window.confirm.
It would be great if you have the HTML code that generates that kind of dialog box so I can take a look.

Adrian.

codecentrix

unread,
Jul 27, 2012, 4:29:10 AM7/27/12
to twebst-autom...@googlegroups.com
I have found how that dialog box is generated:

window.onbeforeunload = function (e) {
    return "custom mesage?";
}

For now I don't think they are supported in Twebst but fortunately support will be added in a next release.

Adrian.

Shawn Ramirtha

unread,
Jul 29, 2012, 12:44:14 PM7/29/12
to twebst-autom...@googlegroups.com

Adrian,

I appreciate you looking into this. 
 
Thanks, Shawn 

Jagath Praveen Kodumagulla

unread,
Dec 28, 2018, 1:30:54 AM12/28/18
to Twebst
Please use below code to close popup.

[DllImport("user32.dll")]
    public static extern bool SetForegroundWindow(IntPtr hWnd);

    [DllImport("user32.dll")]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);


    private static void CloseDialog()
    {
        var handle = FindWindow(null, "Give your window caption/title here");
        SetForegroundWindow(handle);
//send alt+f4 using sendkeys method
        System.Windows.Forms.SendKeys.SendWait("%{F4}");
    }
Thanks, Jagath
Reply all
Reply to author
Forward
0 new messages