This is a migrated thread and some comments may be shown as answers.

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

5 Answers 100 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vidya
Top achievements
Rank 1
Vidya asked on 07 Jul 2013, 07:22 PM

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.


5 Answers, 1 is accepted

Sort by
0
Mario
Telerik team
answered on 08 Jul 2013, 08:57 PM
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
0
Vidya
Top achievements
Rank 1
answered on 10 Jul 2013, 07:30 AM
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.
0
Mario
Telerik team
answered on 15 Jul 2013, 03:57 PM
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
0
Manjunath
Top achievements
Rank 1
answered on 26 Dec 2013, 10:42 AM
how can i  stop execution until the file download with out specifying the time?
0
Mario
Telerik team
answered on 26 Dec 2013, 08:38 PM
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
Tags
General Discussions
Asked by
Vidya
Top achievements
Rank 1
Answers by
Mario
Telerik team
Vidya
Top achievements
Rank 1
Manjunath
Top achievements
Rank 1
Share this question
or