Handle 'Download' dialog

16 posts, 1 answers
  1. Matt
    Matt avatar
    16 posts
    Member since:
    Dec 2011

    Posted 29 Sep 2014 Link to this post

    I'm using Test Studio v2013.2.1524.0 to record my test case. After the listing is exported to Excel file, test case cannot be carried on. It throws the following error on 'Handle Download dialog' step

    'Timed out waiting '25000' msec. for download dialog to be handled.

    How can I solve this problem?

    By the way, my application is Silverlight application.

    Thanks
  2. Matt
    Matt avatar
    16 posts
    Member since:
    Dec 2011

    Posted 29 Sep 2014 Link to this post

    I change the step from recorded step to coded step. Also, I put the try..catch to catch the error.
    public void ExportListingToExcel_CodedStep()
            {
                try
                {
                    string saveLocation = @"C:\Telerik Automated Test\ExportedDocs\ExportedExcel.xls";   
                    DownloadDialogsHandler handler = new DownloadDialogsHandler(ActiveBrowser, DialogButton.SAVE, saveLocation, Manager.Desktop);
                    handler.WaitUntilHandled(25000);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }

    But, ArtofTestRunner crashes after listing is exported to Excel doc. Any ideas?

  3. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 01 Oct 2014 Link to this post

    Hello Matt,

    Which browser are you using for testing? If IE, please make sure that "Notify me when downloads are complete" is checked as shown in the attached screen shot.

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  4. Matt
    Matt avatar
    16 posts
    Member since:
    Dec 2011

    Posted 01 Oct 2014 in reply to Cody Link to this post

    I'm using IE11. Also, "Notify me when downloads are complete" option is turned ON. But, ArtofTestRunner still crashes
  5. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 06 Oct 2014 Link to this post

    Hello Matt,

    But, ArtofTestRunner still crashes

    Now I am confused, is the runner application crashing or are you simply getting an error reported by the test "Timed out waiting '25000' msec. for download dialog to be handled"? These are two radically different symptoms with radically different causes.

    I'm going to assume you just getting the error reported, not an application crash.

    When the download completes in your application, do you get a notification like what is shown in the attached screen shot? If not you'll need to implement the SaveAs dialog handler in code as documented here.

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  6. Matt
    Matt avatar
    16 posts
    Member since:
    Dec 2011

    Posted 06 Oct 2014 in reply to Cody Link to this post

    Even I turned on 'Notify me when downloads are complete' in IE 11

    "'Timed out waiting '25000' msec for download dialog to be handled" error is thrown (refer my first post) after listing is exported to excel If I use Test Studio to add/create the Handle Download dialog step, 


    ArtifTestRunner crashes after listing is exported to excel if I changed the 'Handle Download dialog' into coded step and used try...catch (refer to my second post). 

    Thanks


  7. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 07 Oct 2014 Link to this post

    Hi Matt,

    When you manually download the file using your application, do you get a Download Complete like that shown in the attached screen shot? If not you'll need to implement the SaveAs dialog handler in code as documented here.

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  8. Matt
    Matt avatar
    16 posts
    Member since:
    Dec 2011

    Posted 07 Oct 2014 in reply to Cody Link to this post

    What Telerik library do I need to import or use for SaveAsDialog Handler? I did try to implement the SaveAs dialog handler in code. But, the only handler I can find is DownloadDialogsHandler.

    The following are the library I'm using:

    using Telerik.TestingFramework.Controls.KendoUI;
    using Telerik.WebAii.Controls.Html;
    using Telerik.WebAii.Controls.Xaml;
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Linq;
    using System.IO;

    using ArtOfTest.Common.UnitTesting;
    using ArtOfTest.WebAii.Core;
    using ArtOfTest.WebAii.Controls.HtmlControls;
    using ArtOfTest.WebAii.Controls.HtmlControls.HtmlAsserts;
    using ArtOfTest.WebAii.Design;
    using ArtOfTest.WebAii.Design.Execution;
    using ArtOfTest.WebAii.ObjectModel;
    using ArtOfTest.WebAii.Silverlight;
    using ArtOfTest.WebAii.Silverlight.UI;
    using ArtOfTest.WebAii.Win32;
    using ArtOfTest.WebAii.Win32.Dialogs;

    Thanks
  9. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 08 Oct 2014 Link to this post

    Hello Matt,

    You need:

    using ArtOfTest.WebAii.Win32.Dialogs;
     
    Which it looks like you already have. The class is contained in ArtOfTest.WebAii.dll, which you should already have referenced. Here's sample code how to use it:

    SaveAsDialog dlg = SaveAsDialog.CreateSaveAsDialog(ActiveBrowser, DialogButton.SAVE, "c:\path\file.ext", Manager.Desktop);
     
    // Steps to initiaate the download go here
     
    dlg.WaitUntilHandled(30000);


    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  10. Matt
    Matt avatar
    16 posts
    Member since:
    Dec 2011

    Posted 09 Oct 2014 in reply to Cody Link to this post

    Hello

    After I changed my codes to use SaveAsDialog, file location cannot be typed in automatically. Please find the attached SaveAs dialog box screenshot. This is the dialog box we use in our application.

            [CodedStep(@"New Coded Step")]
            public void ExportListingToExcel_CodedStep()
            {
                string saveLocation = @"C:\Telerik Automated Test\ExportedDocs\ExportedExcel.xls"; 
                SaveAsDialog dlg = SaveAsDialog.CreateSaveAsDialog(ActiveBrowser, DialogButton.SAVE, saveLocation, Manager.Desktop);
                dlg.WaitUntilHandled(30000);

            }


    Thanks
  11. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 12 Oct 2014 Link to this post

    Hello Matt,

    You missed a critical part of the sequence of events. You must call SaveAsDialog.CreateSaveAsDialog before the dialog is present. Then do the action in the application which causes the dialog to open (click the Export/Save button/link or whatever it is) and finally follow that up with dlg.WaitUntilHandled.

    This sequence is required because the dialog handler is only monitoring and looking for new dialogs to be created after the dialog handler object has been instantiated. It will ignore dialogs that are already open when you call SaveAsDialog.CreateSaveAsDialog.

    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  12. Matt
    Matt avatar
    16 posts
    Member since:
    Dec 2011

    Posted 12 Oct 2014 in reply to Cody Link to this post

    File location cannot entered automatically in the second SaveAs form. In my test case, I have 2 separate steps to the export the listing to Excel and Word.

    No problem on export the listing into Excel - file location can be entered automatically. But, file location cannot be entered on exporting the listing to Word.

    I also tried to merge two exports steps into 1 coded step and use the same handler. Still have the same issue.
    But if I put export to Word and Excel into 2 different Test Case, they are running fine. Any idea?

    [CodedStep(@"ExportListingToWord_CodedStep")]
    public void ExportListingToWord_CodedStep()
    {
        try
        {
            string wordLocation = @"C:\Telerik Automated Test\ExportedDocs\ExportedWord.doc";
            SaveAsDialog wordhandler = SaveAsDialog.CreateSaveAsDialog(ActiveBrowser, DialogButton.SAVE, wordLocation, Manager.Desktop);
            Manager.DialogMonitor.AddDialog(wordhandler);
     
            //Code triggers the dialog
            Pages.MEX.SilverlightApp.RMCWord.User.Click(ArtOfTest.WebAii.Core.MouseClickType.LeftClick, 24, 55, ArtOfTest.Common.OffsetReference.TopLeftCorner, ArtOfTest.Common.ActionPointUnitType.Percentage, ((System.Windows.Forms.Keys)(0)));
     
            wordhandler.WaitUntilHandled(30000);
            Manager.DialogMonitor.Stop();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
    }

    Thanks
  13. Answer
    Cody
    Admin
    Cody avatar
    3360 posts

    Posted 15 Oct 2014 Link to this post

    Hello Matt,

    I'm pretty sure the call to:

    Manager.DialogMonitor.Stop();

    Is causing this problem. Stopping the dialog monitor is permanent and will stop Test Studio from handling any dialogs from that point forward. Please remove that line of code.

    If that doesn't help try adding this:

    wordhandler.CurrentState = DialogCurrentState.NotActive;
     
    Place it right after:

    wordhandler.WaitUntilHandled(30000);
     


    Regards,
    Cody
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  14. Victor
    Victor avatar
    9 posts
    Member since:
    Mar 2015

    Posted 01 Sep 2015 Link to this post

    Hello Telerik Team,

     I used following Code to save the downloaded to a specific path location as a child test

     Dim FilePath AS String = "D:\Automation Scripts\REGRESSION SUTIE\Download Files\"
     Dim FileName As String = Data("DownloadFileName")
     Dim SaveLocation As String = FilePath + FileName

        Log.WriteLine (SaveLocation)
        
    Dim handler As SaveAsDialog = SaveAsDialog.CreateSaveAsDialog(ActiveBrowser, DialogButton.SAVE, SaveLocation, Manager.Desktop)
    Manager.DialogMonitor.AddDialog(handler)
    handler.WaitUntilHandled(30000)
    handler.CurrentState = DialogCurrentState.NotActive

     

    Test studio compiles it with no error, but i find strange my parent Test which is using this child Test passes. 

    Issue is 

    1. Save As dialog box opens but the path specified is not written on to the dialog.

    2. Test step passes but action doesn't happen

    3. View log displays the following for that particular child test.

         pls refer to the attached log file.

    Kindly help to solve the situation

     

  15. Victor
    Victor avatar
    9 posts
    Member since:
    Mar 2015

    Posted 01 Sep 2015 in reply to Victor Link to this post

    Attaching files
  16. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 04 Sep 2015 Link to this post

    Hi Matt,

    Please try adding this code 

    Manager.DialogMonitor.Start()

    after Manager.DialogMonitor.AddDialog(handler):

    Let me know if that helps.

    Regards,
    Boyan Boev
    Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top