Below code will help to handle IE Alert pop-up-

HtmlButton Submit = new HtmlButton (browser);

Mouse.Click (Submit);

WinWindow pop = new WinWindow(null);
pop.SearchProperties.Add(“Name”, “Message from webpage”, “ClassName”, “#32770”);
pop.TechnologyName = “MSAA”;
pop.DrawHighlight();

WinText text = new WinText(pop);

text.SearchProperties.Add(“Name”, “Some Name”);
String msg = text.GetProperty(“DisplayText”).ToString();

if (msg.Contains(“Data saved.”))

{
Console.WriteLine(“System is displaying ” + msg);
}
else
{
Console.WriteLine(“System is displaying ” + msg);
}

WinButton ok = new WinButton(pop);
ok.TechnologyName = “MSAA”;
ok.SearchProperties.Add(“Name”, “OK”);
Mouse.Click(ok);

Advertisements

2 thoughts on “How to handle IE Alert pop-up with CodedUI (C#)

  1. Can you please write the code for how to handle the button of web technology pop up. I have a link of Reject Leave and it opens a web technology pop up having Reason and Ok and Cancel buttons. After entering reason, i have written following which does not work:

    UITestControl Click_Reject = new UITestControl(browser);
    Click_Reject.TechnologyName = “Web”;
    Click_Reject.SearchProperties.Add(“ControlType”, “Pane”);
    Click_Reject.SearchProperties.Add(“FriedlyName”, “Reject”);
    Mouse.Click(Click_Reject);

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s