本文整理汇总了C#中IE.AddDialogHandler方法的典型用法代码示例。如果您正苦于以下问题:C# IE.AddDialogHandler方法的具体用法?C# IE.AddDialogHandler怎么用?C# IE.AddDialogHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IE
的用法示例。
在下文中一共展示了IE.AddDialogHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenOnBeforeUnloadReturnJavaDialogIsShown_ClickingOnCancelShouldKeepIEOpen
public void WhenOnBeforeUnloadReturnJavaDialogIsShown_ClickingOnCancelShouldKeepIEOpen()
{
using (var ie = new IE(OnBeforeUnloadJavaDialogURI))
{
var returnDialogHandler = new ReturnDialogHandler();
ie.AddDialogHandler(returnDialogHandler);
var hWnd = ie.hWnd;
// can't use ie.Close() here cause this will cleanup the registered
// returnDialogHandler which leads to a timeout on the WaitUntilExists
var internetExplorer = (IWebBrowser2)ie.InternetExplorer;
internetExplorer.Quit();
returnDialogHandler.WaitUntilExists();
returnDialogHandler.CancelButton.Click();
Thread.Sleep(2000);
Assert.IsTrue(Browser.Exists<IE>(new AttributeConstraint("hwnd", hWnd.ToString())));
// finally close the ie instance
internetExplorer.Quit();
returnDialogHandler.WaitUntilExists();
returnDialogHandler.OKButton.Click();
}
}
示例2: DownloadRun
public void DownloadRun()
{
var dhdl = new FileDownloadHandler(FileDownloadOptionEnum.Run);
var ie = new IE();
ie.AddDialogHandler(dhdl);
ie.WaitForComplete();
ie.GoTo("http://watin.sourceforge.net/WatiN-1.0.0.4000-net-1.1.msi");
dhdl.WaitUntilFileDownloadDialogIsHandled(5);
dhdl.WaitUntilDownloadCompleted(20);
ie.Close();
}
示例3: DownloadOpen
public void DownloadOpen()
{
var dhdl = new FileDownloadHandler(FileDownloadOptionEnum.Open);
var ie = new IE();
ie.AddDialogHandler(dhdl);
ie.WaitForComplete();
ie.GoTo("http://watin.sourceforge.net/WatiNRecorder.zip");
dhdl.WaitUntilFileDownloadDialogIsHandled(5);
dhdl.WaitUntilDownloadCompleted(20);
ie.Close();
}
示例4: DownloadSave
public void DownloadSave()
{
var file = new FileInfo(@"c:\temp\test.zip");
file.Directory.Create();
file.Delete();
Assert.That(file.Exists, Is.False, file.FullName + " file should not exist before download");
var fileDownloadHandler = new FileDownloadHandler(file.FullName);
using (var ie = new IE())
{
ie.AddDialogHandler(fileDownloadHandler);
// ie.GoTo("http://watin.sourceforge.net/WatiN-1.0.0.4000-net-1.1.msi");
ie.GoTo("http://watin.sourceforge.net/WatiNRecorder.zip");
fileDownloadHandler.WaitUntilFileDownloadDialogIsHandled(15);
fileDownloadHandler.WaitUntilDownloadCompleted(200);
}
file = new FileInfo(@"c:\temp\test.zip");
Assert.IsTrue(file.Exists, file.FullName + " file does not exist after download");
}
示例5: TestMultipleIE
public void TestMultipleIE()
{
using (var ie = new IE(TestEventsURI))
{
var handler = new ConfirmDialogHandler();
try
{
ie.AddDialogHandler(handler);
ie.Button(Find.ByValue("Show confirm dialog")).ClickNoWait();
handler.WaitUntilExists(5);
handler.OKButton.Click();
}
finally
{
ie.RemoveDialogHandler(handler);
}
using (var ie2 = new IE(TestEventsURI))
{
var handler2 = new ConfirmDialogHandler();
try
{
ie2.AddDialogHandler(handler2);
ie2.Button(Find.ByValue("Show confirm dialog")).ClickNoWait();
handler2.WaitUntilExists(5);
handler2.OKButton.Click();
}
finally
{
ie2.RemoveDialogHandler(handler2);
}
}
}
}