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
That code looks fine. What path are you attempting to save to?
Kind regards,Cody

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
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

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

now I try this solution

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

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;
}
}

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();
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

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

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();
ActiveBrowser.NavigateTo(
"http://download.html.it/software/getit/8220/avast-free-antivirus/"
);
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);
}
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

now tests run correctly.
Amos.

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
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.