Unable to download the excel file from 'Download Dialog' in IE

6 posts, 0 answers
  1. Vidya
    Vidya avatar
    4 posts
    Member since:
    Jun 2013

    Posted 07 Jul 2013 Link to this post

    Unable to download the excel file from 'Download Dialog' in IE

    Please find below code and also please find attached screen shot for the dialog box.
    My System Configuration: VSTS 2012, Telerik Test Framework( Nunit template) ,Window7 and IE9.

    namespace TestProject2

    {

    public class TelerikNUnitTest1 : BaseTest

        {

    public void SampleWebAiiTest()

            {

    Manager.LaunchNewBrowser(BrowserType.InternetExplorer);

    ActiveBrowser.NavigateTo("http://192.168.10.65/Login.aspx");

    string saveLocation = string.Format("address-{0:HH-mm-ss}.xls", DateTime.Now);

                //Create dialogs

    IEDownloadDialog part1 = new IEDownloadDialog(ActiveBrowser, DialogButton.SAVE, Manager.Desktop);

    Manager.DialogMonitor.Start();

    SaveAsDialog part2 = SaveAsDialog.CreateSaveAsDialog(ActiveBrowser, DialogButton.SAVE, @"C:\Users\1029\Desktop\ExportTest" + saveLocation, Manager.Desktop);

    IEDownloadCompleteDialog part3 = new IEDownloadCompleteDialog(ActiveBrowser, DialogButton.CLOSE, Manager.Desktop);

                //Add each dialog to the monitor

                Manager.DialogMonitor.AddDialog(part1);

                Manager.DialogMonitor.AddDialog(part2);

                Manager.DialogMonitor.AddDialog(part3);

                System.Threading.Thread.Sleep(30000);

                Manager.ActiveBrowser.RefreshDomTree();

               

      //Clicking on below button ‘Save Dialog’ will open         
    Find.ById<HtmlInputImage("ctl00_ctl00_PageContentPlaceHolder_PageContentPlaceHolder_TrademarkSearchSearchResults_ExportExcelButton").Click();

                Manager.ActiveBrowser.RefreshDomTree();

                ActiveBrowser.WaitUntilReady();

               

                part1.WaitUntilHandled();

                part2.WaitUntilHandled(30000);

                part3.WaitUntilHandled(30000);

                System.Threading.Thread.Sleep(10000);

                System.Threading.Thread.Sleep(10000);

            }

        }

    }

    I am getting below exception in debug mode for'part1.WaitUntilHandled();' code line

    ‘Time Out Exception was unhandled by user code. Time Out waiting ‘60000’ msec. for any dialog to be handled.
    And In Run mode below trace is observed

    [Trace] : Unexpected dialog encountered. Closing the dialog, and halting execution.

    Please help me how to save excel file from IE9 download dialog and also please find attached screen shot for dialog box.


  2. Mario
    Admin
    Mario avatar
    8 posts

    Posted 08 Jul 2013 Link to this post

    Hi Vidya,

    The stack trace you provided from the full run suggests that our unexpected dialog handler may be interfering with your test. Please change this setting to 'DoNotHandle' and let me know whether it helps at all:

    Settings.Current.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;


    Regards,
    Mario
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Vidya
    Vidya avatar
    4 posts
    Member since:
    Jun 2013

    Posted 10 Jul 2013 Link to this post

    Hi Mario,

    This time I got errors "[Trace] : Unexpected dialog encountered. Taking no action."

    Error
    In debug mode for'part1.WaitUntilHandled();' code line
    ‘Time Out Exception was unhandled by user code. Time Out waiting ‘60000’ msec. for any dialog to be handled.

    And In Run mode below trace is observed
    [Trace] : Unexpected dialog encountered. Taking no action.
  4. Mario
    Admin
    Mario avatar
    8 posts

    Posted 15 Jul 2013 Link to this post

    Hi Vidya,

    From a higher level perspective, it would certainly be easier to use our more complete dialog handler class 'DownloadDialogsHandler' which wraps the individual parts into one fully integrated class. Applying it to your example would resemble the code below:

    Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
    ActiveBrowser.NavigateTo("http://192.168.10.65/Login.aspx");
    string saveLocation = string.Format("address-{0:HH-mm-ss}.xls", DateTime.Now);
     
    //Create dialogs
    DownloadDialogsHandler dialog = new DownloadDialogsHandler(ActiveBrowser, DialogButton.SAVE, @"C:\Users\1029\Desktop\ExportTest" + saveLocation, Manager.Desktop);
     
    //Clicking on below button ‘Save Dialog’ will open         
    Find.ById <HtmlInputImage>("ctl00_ctl00_PageContentPlaceHolder_PageContentPlaceHolder_TrademarkSearchSearchResults_ExportExcelButton").Click();
     
    //Wait until dialog is handled
    dialog.WaitUntilHandled(30000);

    Please try the alternative method above and let me know if it helps.

    Regards,
    Mario
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  5. Manjunath
    Manjunath avatar
    4 posts
    Member since:
    Dec 2013

    Posted 26 Dec 2013 Link to this post

    how can i  stop execution until the file download with out specifying the time?
  6. Mario
    Admin
    Mario avatar
    8 posts

    Posted 26 Dec 2013 Link to this post

    Hi Manjunath,

    You have to set some value for the timeout argument in the WaitUntilHandled() method, however assuming the timeout is excessive enough, your test case should inherently halt execution until the download completes (or the timeout is reached). Please note that the timeout argument is actually the maximum amount of time allotted for the download to finish, execution will continue as soon as the download completes, regardless of the remaining value. The closest you could get to allowing an infinite amount of time for the download to complete is setting this value to its maximum of '999999999'.

    Regards,
    Mario
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top