public void ClickCancel()
        {
            var handler = new FileDownloadHandler(FileDownloadOptionEnum.Cancel);

            using (new UseDialogOnce(_browser.DialogWatcher, handler))
            {
                _action();
                handler.WaitUntilFileDownloadDialogIsHandled(30);
            }
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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 static string open_and_HandleFileDownload(this WatiN_IE watinIe, string url, string fileName)
        {
            var tmpFile           = fileName.tempFile();
            var waitUntilHandled  = 20;
            var waitUntilDownload = 300;

            var fileDownloadHandler = watinIe.dialogHandler <FileDownloadHandler>();

            if (fileDownloadHandler.notNull())
            {
                watinIe.IE.RemoveDialogHandler(fileDownloadHandler);
            }

            fileDownloadHandler = new FileDownloadHandler(tmpFile);
            watinIe.IE.AddDialogHandler(fileDownloadHandler);


            fileDownloadHandler.field("saveAsFilename", tmpFile);
            fileDownloadHandler.field("hasHandledFileDownloadDialog", false);

            watinIe.open_ASync(url);
            try
            {
                fileDownloadHandler.WaitUntilFileDownloadDialogIsHandled(waitUntilHandled);
                "after: {0}".info("WaitUntilFileDownloadDialogIsHandled");
                fileDownloadHandler.WaitUntilDownloadCompleted(waitUntilDownload);
                "after: {0}".info("WaitUntilDownloadCompleted");
            }
            catch (Exception ex)
            {
                "[WatiN_IE][open_and_HandleFileDownload] {0}".error(ex.Message);
            }

            if (fileDownloadHandler.SaveAsFilename.fileExists())
            {
                "[WatiN_IE] downloaded ok '{0}' into '{1}'".info(url, fileDownloadHandler.SaveAsFilename);
                watinIe.IE.RemoveDialogHandler(fileDownloadHandler);
                return(fileDownloadHandler.SaveAsFilename);
            }
            "[WatiN_IE] failed to download '{0}' ".info(url);
            return(null);
        }
Ejemplo n.º 6
0
        [Test]         // Ignore("Because of timeout issues, run this test manually and not automated"), Category("InternetConnectionNeeded")]
        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");
        }