The following code does not handle download dialog and times out. The workaround is to use Thread.Sleep:
[TestFixture]
public class TelerikTestingFrameworkTests
{
[Test]
public void DownloadAFile()
{
var mySettings = new Settings
{
Web =
{
DefaultBrowser = BrowserType.FireFox
},
ExecutionDelay = 1,
UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle
};
var manager = new Manager(mySettings);
manager.Start();
manager.LaunchNewBrowser();
manager.DialogMonitor.Start();
var browser = manager.ActiveBrowser;
string urlForDownload = @"http://notepad-plus-plus.org/download/v6.5.5.html";
browser.NavigateTo(urlForDownload);
HtmlAnchor a = browser.Find.ByExpression<HtmlAnchor>("TextContent=Notepad++ Installer", "tagname=a");
string saveLocation = System.IO.Path.Combine(@"c:\", "notepadSetup.exe");
File.Delete(saveLocation);
DownloadDialogsHandler handler = new DownloadDialogsHandler(browser, DialogButton.SAVE, saveLocation, browser.Desktop);
a.Click();
handler.WaitUntilHandled(20000);
//System.Threading.Thread.Sleep(10000);
File.Exists(saveLocation).Should().BeTrue();
manager.Dispose();
File.Delete(saveLocation);
}
}