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

IE8 Download file

17 Answers 179 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Simone
Top achievements
Rank 1
Simone asked on 07 Oct 2010, 06:59 PM
hi
i have a problem with download file by WebAii framworke.

i use this code

DownloadDialogsHandler fileDownloadHandler = new DownloadDialogsHandler(myManager.ActiveBrowser, DialogButton.SAVE, path, desktop);
myManager.ActiveBrowser.WaitUntilReady();
 
myManager.ActiveBrowser.Actions.Click(btnSalva);
fileDownloadHandler.WaitUntilHandled(30000);

so btnSalva is button that starts the dialog windows.

so the dialog windows is started, but after few second is closed without download nothing

where do  i mistake?

somebody help me with sample code

thanks

17 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 15 Oct 2010, 08:44 PM
Hello Simone,

That code looks fine. What path are you attempting to save to?

Kind regards,
Cody
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Simone
Top achievements
Rank 1
answered on 27 Oct 2010, 07:20 PM
ok I resolved my problem. the problem was that at one moment the download dialog lost the focus.

But now I have a new problem, if I try my code in another machine when I call NavigateTO(...) method the framework launch a blank page and after 30 seconds it send me a Timeout exception
why this? 
thanks 
0
Cody
Telerik team
answered on 02 Nov 2010, 04:50 PM
Hello Simone,

Let me start by asking one very simple obvious question? Did you do a normal install of the WebAii framework on this other machine? Just copying the code and reference DLL's is not enough to make it work. The installer adds our required IE add-on for tests to work. Also make sure IE is configured as documented here.

Best wishes,
Cody
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Simone
Top achievements
Rank 1
answered on 02 Nov 2010, 11:40 PM
I would compile in release a application in visual c# and use this application on another machine without installa visual studio and WebAii, but only copying the dll. but now I understand that this is impossible. is it  right?
0
Cody
Telerik team
answered on 03 Nov 2010, 12:03 AM
Hello Simone,

You can compile an .exe that uses our framework. On the other machine you must install the WebAii framework for it to work, but you don't need to install anything else beyond that and your application (i.e. it is not necessary to install Visual Studio).

Sincerely yours,
Cody
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Simone
Top achievements
Rank 1
answered on 05 Nov 2010, 01:42 PM
ok thanks
now I try this solution
0
Amos
Top achievements
Rank 1
answered on 11 Nov 2010, 11:33 AM
Hi Simone,
I have the same problem, can you tell me how do you do to resolve the problem of the download dialog's focus, please?
Thanks
0
Simone
Top achievements
Rank 1
answered on 13 Nov 2010, 01:33 PM
sorry for the late response 
I use the follow solution.
for the moment it's work fine, but it isn't a great solution.

the code was written in visual studio 2008
sorry for the late response 
I use the follow solution.
for the moment it's work fine, but it isn't a great solution.

the code was written in visual studio 2008
sorry for the late response 
I use the follow solution.
for the moment it's work fine, but it isn't a great solution.

the code was written in visual studio 2008
sorry for the late response 
I use the follow solution.
for the moment it's work fine, but it isn't a great solution.

the code was written in visual studio 2008
sorry for the late response.
I use the follow solution:
(for the moment it's work fine, but form me it isn't a great solution)

the code i was written in visual studio 2008

in lista[5] there is the nRetry value, if you'll  want you'll write a fix value and delete the TryParse 
private void CreateDownloadDialog(string path, Element button)
{
    int nRetry = 0;
    int.TryParse(lista[5], out nRetry);
    while (nRetry-- > 0)
    {
        IEDownloadDialog iedownload = new IEDownloadDialog(myManager.ActiveBrowser, DialogButton.SAVE, myManager.Desktop);
        myManager.DialogMonitor.AddDialog(iedownload);
 
        SaveAsDialog saveas = new SaveAsDialog(myManager.ActiveBrowser, DialogButton.SAVE, path, myManager.Desktop);
        myManager.DialogMonitor.AddDialog(saveas);
 
        IEDownloadCompleteDialog iedownloadComplete = new IEDownloadCompleteDialog(myManager.ActiveBrowser, DialogButton.CLOSE, myManager.Desktop);
        myManager.DialogMonitor.AddDialog(iedownloadComplete);
        try
        {
            myManager.DialogMonitor.Start();
 
            myManager.ActiveBrowser.Actions.Click(button);
            myManager.ActiveBrowser.WaitUntilReady();
 
            iedownload.WaitUntilHandled();
            saveas.WaitUntilHandled();
            iedownloadComplete.WaitUntilHandled();
        }
        catch (Exception ex)
        {
            iedownload.Window.Close();
            myManager.ActiveBrowser.Window.SetFocus();
            Debug.WriteLine("riprova handling dialog");
            continue;
        }
        finally
        {
            myManager.DialogMonitor.Stop();
            myManager.DialogMonitor.RemoveDialog(iedownloadComplete);
            myManager.DialogMonitor.RemoveDialog(saveas);
            myManager.DialogMonitor.RemoveDialog(iedownload);
        }
        break;
    }
 
     
}
0
Amos
Top achievements
Rank 1
answered on 15 Nov 2010, 02:40 PM

Thank you for your solution but it  does not work in my case. My problem is whit the code in this reply.
In fact, when I try to execute this code IE8 crash everytime like in the second image.
I have tried whit the DownloadDialogsHandler but is the same.
For this test i used IE8, windows 7 64 bit and visual studio 2010
I supposed that the problem is that appear two dialogs like the first image and not only one, 
in fact I try to execute the same code whit another site where appear only one dialogs at time and 
IE8 not crash. Can someone help me?
Thanks.


Manager.Current.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
 
IEDownloadDialog downloadDialog = new IEDownloadDialog(Manager.Current.ActiveBrowser, DialogButton.SAVE, Manager.Current.Desktop);
Manager.Current.DialogMonitor.AddDialog(downloadDialog);
 
SaveAsDialog saveAsDialog = new SaveAsDialog(Manager.Current.ActiveBrowser, DialogButton.SAVE, @"C:\Users\DEVELOPER\Downloads\test.rel", Manager.Current.Desktop);
Manager.Current.DialogMonitor.AddDialog(saveAsDialog);
 
IEDownloadCompleteDialog completeDialog = new IEDownloadCompleteDialog(Manager.Current.ActiveBrowser, DialogButton.CLOSE, Manager.Current.Desktop);
Manager.Current.DialogMonitor.AddDialog(completeDialog);
 
Manager.Current.DialogMonitor.Start();
 
Click 'ScaricaFileProvvisorioLink'             
ModiPages.NewAgeSistemaAgenzia.FrameMain.ScaricaFileProvvisorioLink.Click();
 
downloadDialog.WaitUntilHandled(_timeout);
 
saveAsDialog.WaitUntilHandled(_timeout);
 
completeDialog.WaitUntilHandled(_timeout);
 
Manager.Current.DialogMonitor.Stop();
0
Cody
Telerik team
answered on 16 Nov 2010, 09:40 PM
Hi Amos,

Here is a complete working download sample you can use to model your code after. Please make you code resemble this structure.

[TestMethod]
public void DownloadTest()
{
    Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
 
    Manager.LaunchNewBrowser();
    ActiveBrowser.NavigateTo("http://www.thinkbroadband.com/download.html");
 
    DownloadDialogsHandler fileDownloadHandler = new DownloadDialogsHandler(Manager.ActiveBrowser,
                                                        DialogButton.SAVE, @"c:\temp\5mb.zip", Manager.Desktop);
    Find.ByExpression<HtmlImage>("src=http://www.thinkbroadband.com/images/iconDownload-5MB.png", "tagname=img").Click();
 
    fileDownloadHandler.WaitUntilHandled(30000);
 
}

If you still cannot get it to work, please post your entire code for us to review. 

Kind regards,
Cody
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Simone
Top achievements
Rank 1
answered on 16 Nov 2010, 11:23 PM
In my case I work with IE 8 and Windows XP 32 bit with Visual Studio 2008
0
Cody
Telerik team
answered on 17 Nov 2010, 12:24 AM
Hi Simone,

That's just fine. The code I posted will work for IE7, IE8, Firefox, Safari and Chrome in all versions of Windows since and including XP (32 bit and 64 bit).

Kind regards,
Cody
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Amos
Top achievements
Rank 1
answered on 17 Nov 2010, 10:42 AM
Hi,
thank you for your solution, I tried to execute whitout change anything and it works but when I tried to execute in my case it not works but it crash IE8 like in image1 and image2. The problem is that in my case the dialogs that IE open when I tried to dowload the file are two and not only one like in your case. To reproduce my case you can execute this code infact the image1 and image2 are the snapshot made when this code is running.
Do you have any idea to resolve this problem?
Thanks.

[TestMethod]
public void DownloadTest()
{
   Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
    
   Manager.LaunchNewBrowser();
 
 
   DownloadDialogsHandler fileDownloadHandler = new DownloadDialogsHandler(Manager.ActiveBrowser,DialogButton.SAVE, @"c:\temp\setup_av_free_ita.exe", Manager.Desktop);
 
   Find.ByExpression<HtmlControl>("TextContent=Clicca qui", "tagname=strong").Click();
 
   fileDownloadHandler.WaitUntilHandled(30000);
}

0
Cody
Telerik team
answered on 17 Nov 2010, 07:29 PM
Hello Amos,

Thank you for sending me a working sample test I can use to repro your problem. That really helps.

This is a known bug we found and fixed about a month ago. If you upgrade to the latest release you will no longer have this problem.

Also I recommend changing your .Click() line of code to this:

Find.ByExpression<HtmlAnchor>("Title=Clicca qui").Click();

It should be more reliable across multiple browsers and make you more immune language differences if the web page is rendered in different languages. Lastly this clicks on the Anchor element (technically the correct element) instead of the text "Clicca qui".

Kind regards,
Cody
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Amos
Top achievements
Rank 1
answered on 22 Nov 2010, 02:34 PM
Thank you so much,
now tests run correctly.
Amos.
0
Satyajeet
Top achievements
Rank 1
answered on 16 Jan 2012, 12:35 PM
Hi,

I am using the below code to save a file download dialog to a particular path.
Below is my code.

Manager.Settings.UnexpectedDialogAction =

 

UnexpectedDialogAction.DoNotHandle;

 

 

 

DownloadDialogsHandler handler = new DownloadDialogsHandler(ActiveBrowser, DialogButton.SAVE, @"D:\address.xls", Manager.Desktop);

 

Manager.ActiveBrowser.WaitUntilReady();

Pages.abcd.FrameFrame1.DownloadlinkLink.Click(

 

false);

 

handler.WaitUntilHandled(9000);

I am getting the attached exception and the file doesnot save.
It opens the SaveAs dialog and doesnot pick the given path and freezes.
Attached is the screenshot of steps performed to save.

Could you please help.

Thanks,
Satya

0
Anthony
Telerik team
answered on 16 Jan 2012, 07:00 PM
Hello Satya,

Please see my response in your other forum post.

Kind regards,
Anthony
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Simone
Top achievements
Rank 1
Answers by
Cody
Telerik team
Simone
Top achievements
Rank 1
Amos
Top achievements
Rank 1
Amos
Top achievements
Rank 1
Satyajeet
Top achievements
Rank 1
Anthony
Telerik team
Share this question
or