public void DownloadDialogNotUniversal() { string fileToDownload = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, @"myw3schoolsimage.jpg"); if (File.Exists(fileToDownload)) { File.Delete(fileToDownload); } var dialog = new DownloadDialogsHandler( manager.ActiveBrowser, DialogButton.SAVE, fileToDownload, manager.Desktop); manager.DialogMonitor.Start(); manager.ActiveBrowser.NavigateTo( "http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_a_download"); ArtOfTest.WebAii.Core.Browser myFrame = manager.ActiveBrowser.Frames.ById("iframeResult"); HtmlImage image = myFrame.Find.AllByTagName <HtmlImage>("img")[0]; image.Click(false); dialog.WaitUntilHandled(); }
public void DownloadPDFReport(string filePath) { if (File.Exists(filePath)) { File.Delete(filePath); this.Wait.Explicit(this.ExplicitTimeout); } DownloadDialogsHandler dialog = new DownloadDialogsHandler(Manager.ActiveBrowser, DialogButton.SAVE, filePath, Manager.Desktop); Manager.DialogMonitor.Start(); this.DownloadPDFButton.Click(); dialog.WaitUntilHandled(this.WaitUntilHandledTimeout); }
public static void DownloadFile( Action action, string saveLocation) { Manager.Current.DialogMonitor.Start(); Browser browser = Manager.Current.ActiveBrowser; DownloadDialogsHandler handler = new DownloadDialogsHandler( browser, DialogButton.SAVE, saveLocation, browser.Desktop); action(); handler.WaitUntilHandled(); }
public void DownloadDialogs() { // Note: // Given that the download is usually a sequence of dialogs, // WebAii wraps the download sequence using the DownloadDialogHandler. // The DownloadDialogHandler supports Cancel or Save operations to a location on disk. // If you want more control over each dialog, the dialogs are available // under the Win32.Dialogs namespace // // Also the DialogHandler managers its own instance of the DialogMonitor so it won't affect your own // Manager.DialogMonitor instance of your class. // // Option I - Using the generic handler. // Element e = Find.ByTagIndex("a", 0); string saveLocation = Path.Combine(Path.GetTempPath(), "json2.txt"); if (File.Exists(saveLocation)) { File.SetAttributes(saveLocation, FileAttributes.Normal); File.Delete(saveLocation); } DownloadDialogsHandler handler = new DownloadDialogsHandler(ActiveBrowser, DialogButton.SAVE, saveLocation, Desktop); Actions.Click(e); handler.WaitUntilHandled(30000); // // Option II - Using the built in support in HtmlControls // if (File.Exists(saveLocation)) { File.SetAttributes(saveLocation, FileAttributes.Normal); File.Delete(saveLocation); } Find.ByTagIndex <HtmlAnchor>("a", 0).Download(false, DownloadOption.Save, saveLocation, 20000); }
protected void DownloadFileFromWeb(string filename, DownloadFileTypes fileType, RadToolBar rtb) { RadToolBarItem rtb_item01 = null; switch (fileType) { case DownloadFileTypes.CSV: { rtb_item01 = rtb.FindItemByText("CSV"); break; } case DownloadFileTypes.INVPNG: { rtb_item01 = rtb.FindItemByText("Przezroczysty (PNG)"); break; } case DownloadFileTypes.PNG: { rtb_item01 = rtb.FindItemByText("PNG"); break; } case DownloadFileTypes.PPTX: { rtb_item01 = rtb.FindItemByText("Power Point (PPTX)"); break; } case DownloadFileTypes.XLS: { rtb_item01 = rtb.FindItemByText("Excel (XLS)"); break; } case DownloadFileTypes.XLSX: { rtb_item01 = rtb.FindItemByText("Aktualizowalny Excel (XLSX)"); break; } } Assert.IsNotNull(rtb_item01, "Could not find option when trying to download the file"); DownloadDialogsHandler handler = new DownloadDialogsHandler(ActiveBrowser, DialogButton.SAVE, dir + filename, Desktop); try { rtb_item01.Click(); } catch { } ActiveBrowser.Window.SetFocus(); handler.WaitUntilHandled(20000); Assert.IsFalse(ActiveBrowser.ContainsText("Application encountered an unexpected error. We are very sorry for any inconvenience."), "BinocleWeb Crashed !"); System.Threading.Thread.Sleep(4000); DirectoryInfo directory = new DirectoryInfo(dir); Assert.IsTrue(directory.GetFiles(filename, SearchOption.AllDirectories).Length != 0); FileInfo file = directory.GetFiles(filename, SearchOption.TopDirectoryOnly)[0]; file.Delete(); Assert.IsTrue(directory.GetFiles(filename, SearchOption.AllDirectories).Length == 0); }
public void SampleWebAiiTest() { Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle; Manager.Settings.Web.DefaultBrowser = BrowserType.InternetExplorer; // Launch an instance of the browser Manager.LaunchNewBrowser(); DownloadDialogsHandler downloadDialog = new DownloadDialogsHandler(ActiveBrowser, DialogButton.SAVE, "VS90sp1-KB945140-ENU", Manager.Desktop); // Navigate to : 'http://www.microsoft.com/downloads/en/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=en' ActiveBrowser.NavigateTo("http://www.microsoft.com/downloads/en/details.aspx?FamilyId=FBEE1648-7106-44A7-96" + "49-6D9F6D58056E&displaylang=en"); // Click 'DownloadSpan' ActiveBrowser.Window.SetFocus(); // Pages.DownloadDetailsMicrosoft.DownloadSpan.ScrollToVisible(ArtOfTest.WebAii.Core.ScrollToVisibleType.ElementTopAtWindowTop); //Pages.DownloadDetailsMicrosoft.DownloadSpan.MouseClick(); // Please make sure you call the current dialog handler before the dialog actually appears on the screen! // Handle 'Download' dialog. DownloadPath property must be set manually. downloadDialog.WaitUntilHandled(30000); }
public void DownloadFile(Action printButtonClick) { DownloadDialogsHandler downloadFile = new DownloadDialogsHandler(Telerik.ActiveBrowser, DialogButton.SAVE, @"D:\testtest.pdf", Telerik.ActiveBrowser.Manager.Desktop); printButtonClick(); //KeyBoardSimulator.KeyPress(Keys.Back); downloadFile.WaitUntilHandled(Config.PageClassSettings.Default.MaxTimeoutValue * 10); }