public void ClickCancel() { var handler = new FileDownloadHandler(FileDownloadOptionEnum.Cancel); using (new UseDialogOnce(_browser.DialogWatcher, handler)) { _action(); handler.WaitUntilFileDownloadDialogIsHandled(30); } }
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(); }
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(); }
public void ClickSave(string fullFileNameWithPath, int waitDurationInSecondsUntilFileDownloadDialogIsHandled, int waitDurationInSecondsUntilDownloadCompleted) { _browser.BringToFront(); var handler = new FileDownloadHandler(fullFileNameWithPath); using (new UseDialogOnce(_browser.DialogWatcher, handler)) { _action(); handler.WaitUntilFileDownloadDialogIsHandled(waitDurationInSecondsUntilFileDownloadDialogIsHandled); handler.WaitUntilDownloadCompleted(waitDurationInSecondsUntilDownloadCompleted); File.Exists(fullFileNameWithPath).ShouldBeTrue(String.Format("file {0} should exist", fullFileNameWithPath)); File.Delete(fullFileNameWithPath); } }
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"); }
private static void DescargarFacturasListadas(IE browser, string carpeta) { //Creating the directory if it doesn't exists if (!System.IO.Directory.Exists(carpeta)) { System.IO.Directory.CreateDirectory(carpeta); } Log.Write("Descargando", Log.Information); foreach (var link in browser.Images.Where(img => img.Name == "BtnDescarga")) { //obtener folio fiscal string folio = link.Parent.Parent.NextSibling.Text; string archivo = String.Format("{0}.xml", folio); string rutaCompleta = Path.Combine(carpeta, archivo); //si ya esta descargada, no la brincamos if (File.Exists(rutaCompleta)) { continue; } //download xml link.Click(); Log.Write("Click Descargando " + archivo, Log.Information); FileDownloadHandler fileDownloadHandler = new FileDownloadHandler(rutaCompleta); browser.AddDialogHandler(fileDownloadHandler); try { fileDownloadHandler.WaitUntilFileDownloadDialogIsHandled(30); fileDownloadHandler.WaitUntilDownloadCompleted(30); } catch { //si no se descargo, lanzamos error if (!File.Exists(rutaCompleta)) { throw; } } finally { browser.RemoveDialogHandler(fileDownloadHandler); } } }
public void Export_Private_Message_Test() { this.browser.GoTo("{0}yaf_cp_pm.aspx".FormatWith(TestConfig.TestForumUrl)); Assert.IsTrue(this.browser.ContainsText("Archive"), "Private Message Function is not available for that User, or is disabled"); this.browser.Link(Find.ByText("Sent Items")).Click(); // Select the First Message this.browser.CheckBox(Find.ById(new Regex("_ItemCheck_0"))).Click(); this.browser.Link(Find.ById(new Regex("_MessagesView_ExportSelected"))).Click(); // Switch to XML Export this.browser.RadioButton(Find.ByValue("txt")).Click(); var filePath = Path.GetFullPath(@"..\..\testfiles\"); try { var download = new FileDownloadHandler(Path.Combine(filePath, "textExport.txt")); this.browser.AddDialogHandler(download); this.browser.Button(Find.ById(new Regex("_OkButton"))).ClickNoWait(); download.WaitUntilFileDownloadDialogIsHandled(15); download.WaitUntilDownloadCompleted(150); this.browser.RemoveDialogHandler(download); } catch (WatiNException) { Assert.Pass("Test Currently doesn't work in IE9"); } var file = new FileStream(Path.Combine(filePath, "textExport.txt"), FileMode.Open, FileAccess.Read); var sr = new StreamReader(file); var fileContent = sr.ReadToEnd(); sr.Close(); file.Close(); Assert.IsTrue(fileContent.Contains("This is an automtated Test Message generated at ."), "Message Export Failed"); }