Reputation:
HI ,
Am automating a website, when tried to login its dispalying one security alert pop up. Wanted to click "Yes" of that pop up,Can anyone give the solution for this.
Upvotes: 2
Views: 2594
Reputation:
I had a mix of security warnings and certificate warnings every time the server got new code. This works for me:
browser.AddDialogHandler(new DialogHandlerHelper());
browser.AddDialogHandler(new SecurityAlertDialogHandler());
Assert.IsTrue(browser.Link(Find.ByText("Login")).Exists);
browser.Link(Find.ByText("Login")).Click();
if (browser.Element("expertContentHeading").Exists)
{
browser.Element("expertContentHeading").Click();
browser.Button("exceptionDialogButton").Click();
int Handle = browser.hWnd.ToInt32();
object BT = true;
WshShell WSH = new WshShell();
WSH.SendKeys("{TAB}", ref BT);
WSH.SendKeys("{TAB}", ref BT);
WSH.SendKeys("{TAB}", ref BT);
WSH.SendKeys("{TAB}", ref BT);
WSH.SendKeys("{ENTER}", ref BT);
}
if (browser.Links.Exists("overridelink"))
{
browser.Link("overridelink").Click();
}
Upvotes: 1
Reputation: 1382
There are two ways to handle this, add a dialog handler at the start of the test or add one explicitly when you need it. Here is how you add one at the start that runs is a seperate thread.
IE ie = new IE();
ie.AddDialogHandler( new SecurityDialoghandLer() .. or the appropriate dialog handler ...);
The rest of your test ...
Upvotes: 1