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

Downloading files in IE7

18 Answers 160 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
kovyar
Top achievements
Rank 1
kovyar asked on 29 Jul 2010, 04:54 PM
HI all,

I'd like to share an interesting (I hope so) problem.
When downloading files in IE 7, we have three dialog windows: download confirmation, save file dialog and the window after download.
There are corresponding dialogs in WebAii framework: IEDownloadDialog, SaveAsDialog and IEDownloadCompleteDialog.

So, we use them to handle the downloading process in the way as described below.
string fname = "c:\download.doc";
 
IEDownloadDialog iedownload = new IEDownloadDialog(
   Browser,
   DialogButton.SAVE,
   Manager.Desktop);
 
  Manager.DialogMonitor.AddDialog(iedownload);
 
  SaveAsDialog saveas = new SaveAsDialog(
   Browser,
   DialogButton.SAVE,
   fname,
   Manager.Desktop);
 
  Manager.DialogMonitor.AddDialog(saveas);
 
  IEDownloadCompleteDialog iedownloadComplete = new IEDownloadCompleteDialog(
   Browser,
   DialogButton.CLOSE,
   Manager.Desktop);
 
  Manager.DialogMonitor.AddDialog(iedownloadComplete);
  Manager.DialogMonitor.Start();
 
  downloadExcelLink.MouseClick(MouseClickType.LeftClick);
 
  Thread.Sleep(15000);   
  Manager.DialogMonitor.Stop();

But there is one problem: as far as I understand, for some small period of time the close button on the last dialog is disabled (I have no idea why, really). So the dialog handler clicks it when the button is inactive and nothing happens.
I didn't encounter this problem while using WebAii 1.1, it started to appear only after migration to WebAii 2.0.

Looking forward for hearing any ideas.

Thanks, 
Yaroslav

18 Answers, 1 is accepted

Sort by
0
Missing User
answered on 30 Jul 2010, 08:50 PM
Hi Yaroslav,

I gave the code a try in the latest framework version in IE7 and it seemed to work for me. Just to confirm, have you configured IE as in this link?

Sincerely,
Nelson Sin
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
kovyar
Top achievements
Rank 1
answered on 31 Jul 2010, 04:23 PM

Hi Nelson,

yes, IE is configured well.

As I checked the DialogMonitor, all the three dialogs were handled once, but the last one was not closed.

And just after the downloading, I could see with my own eyes that "Close" button was disabled for a small period of time.

I think it's just special behavior of IE while downloading Office documents, but I don't know how to deal with it.

Thanks,

Yaroslav

0
kovyar
Top achievements
Rank 1
answered on 02 Aug 2010, 12:30 PM
Hi,

I've wrote a small test web page and a code which downloads the file.

Settings mySettings = new Settings(BrowserType.InternetExplorer, @"d:\");
mySettings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
 
 
Manager myManager = new Manager(mySettings);
 
myManager.Start();
myManager.LaunchNewBrowser();
 
var Browser = myManager.ActiveBrowser;
 
myManager.ActiveBrowser.NavigateTo("http://aspspider.info/kovyar/test.html");
 
string fname = @"c:\download.doc";
 
IEDownloadDialog iedownload = new IEDownloadDialog(
    Browser,
    DialogButton.SAVE,
    myManager.Desktop);
 
myManager.DialogMonitor.AddDialog(iedownload);
 
SaveAsDialog saveas = new SaveAsDialog(
    Browser,
    DialogButton.SAVE,
    fname,
    myManager.Desktop);
 
myManager.DialogMonitor.AddDialog(saveas);
 
IEDownloadCompleteDialog iedownloadComplete = new IEDownloadCompleteDialog(
    Browser,
    DialogButton.CLOSE,
    myManager.Desktop);
 
myManager.DialogMonitor.AddDialog(iedownloadComplete);
myManager.DialogMonitor.Start();
 
Element mylink1 = myManager.ActiveBrowser.Frames[2].Find.ById("touch_me");
HtmlControl htmlControl1 = new HtmlControl(mylink1);
htmlControl1.Click();
 
Thread.Sleep(30000); //wait for downloading
 
myManager.DialogMonitor.Stop();
 
myManager.Dispose();

It downloads the file (it's C# language specification, 2.7 Mb) from free hosting and saves to the hard drive.
On the attached screenshot you can see that the last dialog was handled once, just like the others.

But the last dialog remains open even after the call to Dispose().

All the best,
Yaroslav
0
Cody
Telerik team
answered on 02 Aug 2010, 08:23 PM
Hello kovyar,

Thank you for reporting this bug. Which OS are you running this under? I have reproduced this symptom on XP.

Greetings,
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
kovyar
Top achievements
Rank 1
answered on 02 Aug 2010, 08:53 PM

Hi Cody,

And thanks for the answer.

'm running Windows XP, so, maybe, that's the only platform where this bug exists.

And, well, I wonder if there are any ways repairing it until you release a fix?

Kind regards,

Yaroslav

0
Cody
Telerik team
answered on 02 Aug 2010, 09:18 PM
Hi kovyar,

Do you have the option of running your test in Firefox or Safari? It appears the download dialog handling works properly on XP for those two browsers.

Another option is to simply live with it. I find in my testing that the test still passes even though the dialog is left open.

Also you can simplify your code significantly by taking advantage of the DownloadDialogsHandler object like this:

[TestMethod]
public void DownloadTest()
{
    Settings mySettings = new Settings(BrowserType.InternetExplorer, @"d:\");
    mySettings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
    Manager myManager = new Manager(mySettings);

    myManager.Start();
    myManager.LaunchNewBrowser();
    var Browser = myManager.ActiveBrowser;
    myManager.ActiveBrowser.NavigateTo("http://aspspider.info/kovyar/test.html");

    string fname = @"c:\download.doc";
    DownloadDialogsHandler ddh = new DownloadDialogsHandler(myManager.ActiveBrowser, DialogButton.SAVE, fname, myManager.Desktop);

    Element mylink1 = myManager.ActiveBrowser.Frames[2].Find.ById("touch_me");
    HtmlControl htmlControl1 = new HtmlControl(mylink1);
    htmlControl1.Click();

    
ddh.WaitUntilHandled(30000);

    myManager.DialogMonitor.Stop();
    myManager.Dispose();
}


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
kovyar
Top achievements
Rank 1
answered on 02 Aug 2010, 09:27 PM

Hi Cody.

Thanks for the code, I'll try to use the DownloadDialogHandler.

I think I'll manage to write about my experience with it tomorrow.

Concerning Firefox: there is something wrong with our application's layout that no controls at all can be clicked on the page in FF.

Maybe, we should try using Safari, but I'm not sure if it make things better.

Thanks,

Yaroslav

0
Cody
Telerik team
answered on 02 Aug 2010, 10:14 PM
Hi kovyar,

Sorry about your Firefox problems. Can you upgrade to IE8? That seems to work great for me in my testing.

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
kovyar
Top achievements
Rank 1
answered on 03 Aug 2010, 08:55 AM
Hi Cody,

we are upgrading our tests to support both IE8 and FF, but we still have to support IE7 as well.
So we should make it work.

Thanks,
Yaroslav
0
Cody
Telerik team
answered on 03 Aug 2010, 07:50 PM
Hi kovyar,

Yes you are correct. It even affects our WebUI Test Studio product. I have filed bug 70587 on this problem.

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
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 06 Oct 2010, 03:20 PM
I am having a problem with initiation the download dialog in IE7 can someone please help?

Here is my code:
UploadFileDialogClick("ctl00_ContentPlaceHolder1_ElectronicSubmission1_ipFileUpload", @"F:\test.doc");
  
private void UploadFileDialogClick(string controlId, string file)
        {
  
            browser.WaitUntilReady();
            browser.RefreshDomTree();
              
            //Start the file download handler
            DownloadDialogsHandler ddh = new DownloadDialogsHandler(manager.ActiveBrowser, DialogButton.SAVE, file, manager.Desktop);
  
            //Click On Button To Display File Dialog
            ClickOnItemById(controlId);
  
            //Wait for download to complete
            ddh.WaitUntilHandled(30000);
            manager.DialogMonitor.Stop(); 
  
        }
  
private void ClickOnItemById(string controlId)
        {
  
            browser.WaitUntilReady();
            browser.RefreshDomTree();
  
            Element element = browser.Find.ById(controlId);
            if (element != null)
            {
                browser.Manager.Desktop.Mouse.Click(MouseClickType.LeftClick, element.GetRectangle());
            }
            else
            {
                Assert.IsNull(element, "ClickOnItemById: Element could not be found with the id '" + controlId + "'");
            }
  
        }
 when I debug my code I seem to be able to find the control and perform the click action but no dialog appears
and the dialog handle then times out

the fileupload button in in a modalwindow, as can been seen on the image I sent.

here is my markup for the modelwindow

<asp:Panel ID="pnlBrowseForFiles" runat="server" Style="display: none" CssClass="modalPopup">
    <table border="0" cellpadding="3" cellspacing="0">
        <tr>
            <td colspan="3" align="center">
                <span class="BoldPrompt">Resume Pack Item Upload</span>
            </td>
        </tr>
        <tr>
            <td align="right">
                   
            </td>
            <td style="width: 5px">
                   
            </td>
            <td>
                   
            </td>
        </tr>
        <tr>
            <td align="right">
                Item Type:
            </td>
            <td>
                   
            </td>
            <td>
                <asp:DropDownList ID="ddlFileTypes" runat="server" Width="192px">
                    <asp:ListItem Value="Resume">Resume</asp:ListItem>
                    <asp:ListItem Value="Cover Letter" Selected="True">Cover Letter</asp:ListItem>
                    <asp:ListItem Value="Transcript">Transcript</asp:ListItem>
                    <asp:ListItem Value="Other">Other</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td align="right">
                File Path:
            </td>
            <td align="center">
                <asp:RequiredFieldValidator ID="rfvFile" runat="server" ErrorMessage="*" Text="*"
                    ControlToValidate="ipFileUpload"></asp:RequiredFieldValidator>
            </td>
            <td>
                <input id="ipFileUpload" style="width: 275px;" type="file" size="28" name="ipFileUpload"
                    runat="server" />
            </td>
        </tr>
        <tr>
            <td colspan="3">
                   
            </td>
        </tr>
        <tr>
            <td colspan="3" align="center">
                <span class="Alert">Note: Maximum file size allowed is 4096kb (4 MB)</span>
            </td>
        </tr>
        <tr>
            <td colspan="3">
                   
            </td>
        </tr>
        <tr>
            <td colspan="3" align="center">
                <asp:Button ID="btnAdd" runat="server" Text="Upload" OnClick="btnAdd_Click" />
                <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="False">
                </asp:Button>
            </td>
        </tr>
    </table>
</asp:Panel>
<cc1:ModalPopupExtender ID="mpeBrowseForFiles" runat="server" TargetControlID="lbBrowseForFiles"
    PopupControlID="pnlBrowseForFiles" BackgroundCssClass="modalBackground" CancelControlID="btnCancel" />





0
Cody
Telerik team
answered on 06 Oct 2010, 03:57 PM
Hi Andrew,

I am a little confused by the screenshot. You speak of a problem getting download dialog handling to work, show code for download dialog handling, but the screenshot shows a "Resume Pack Item Upload" dialog??? So are we really dialog with downloading a file from the web server or uploading a file to the web server?

In addition, this particular dialog looks like a very custom dialog. Is it created via Flash? Our dialog handlers only work with the standard IE dialogs.

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
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 06 Oct 2010, 04:01 PM
I am trying to initiate the fileupload dialog but I cannot seen to get it to appear, i can find the element and perform the click action but nothing happens
0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 06 Oct 2010, 04:29 PM
the window in the screen shot is just a panel controedl by a ModalPopupExtender (see the html markup I included)
0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 06 Oct 2010, 08:41 PM
ok, I got it to work.

by using the generic type method and giving it a type of HtmlInputFile then I called its click method?

I was just wondering what is the best way to iteract with the controls as Elements or as there type (in this case HtmlInputFile)
0
Cody
Telerik team
answered on 06 Oct 2010, 11:35 PM
Hello Andrew,

Generally it's better to use their specific type as you will often find extra methods & properties on the specific types that you don't have with the the generic Element.

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
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 07 Oct 2010, 01:33 PM
ok, thanks

do you know why the click worked on the typed HTMLInputFile object vs using the element.

sorry one other issue:

I am uploading 3 files in my test, the first upload is fine, but the next 2 uploads use the filename from the first file even though I am setting the file name each file to a different file.


UploadFileDialogClick("ctl00_ContentPlaceHolder1_ElectronicSubmission1_ipFileUpload", @"\\SERVERNAME\file1.txt");
  
  
UploadFileDialogClick("ctl00_ContentPlaceHolder1_ElectronicSubmission1_ipFileUpload", @"\\SERVERNAME\file2.txt");
  
UploadFileDialogClick("ctl00_ContentPlaceHolder1_ElectronicSubmission1_ipFileUpload", @"\\SERVERNAME\file3.txt");
  
  
  
private void UploadFileDialogClick(string controlId, string file)
            {
  
                //Refresh DOM
                RefreshDOM();
  
                //Start Dialog Monitor
                FileUploadDialog dialog = new FileUploadDialog(browser, file, DialogButton.OPEN);
                manager.DialogMonitor.AddDialog(dialog);
                manager.DialogMonitor.Start();
  
                //Click On HtmlInputFile Button
                HtmlInputFileClickById(controlId);
  
                //Stop Dialog Monitor
                manager.DialogMonitor.Stop(); 
              
            }
  
private void HtmlInputFileClickById(string controlId)
            {
  
                //Refresh DOM
                RefreshDOM();
  
                //Perform Click Action
                HtmlInputFile control = browser.Find.ById<HtmlInputFile>(controlId);
                if (control != null)
                {
                    control.Wait.ForVisible();
                    control.Click();
                }
                else
                {
                    Assert.IsNull(control, "HtmlInputFileClickById: HtmlInputFile object could not be found with the id '" + controlId + "'");
                }
  
            }
0
Cody
Telerik team
answered on 12 Oct 2010, 05:57 PM
Hello Andrew,

The framework knows that n HTMLInputFile has a special structure. Thus it is able to click on the right spot where as a plain Element object is going to be clicked on the wrong spot for an HTMLInputFile element. They can't be treated equally.

For your upload problem, I am guessing you are creating and adding multiple FileUploadDialog objects. The The first one in the chain is what's going to get used. You could either:

  1. Use a global FileUploadDialog and change it's FilePath property in between upload tests
  2. Call Manager.DialogMonitor.RemoveDialog(dialog) when you call .Stop() to remove it from the chain

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
Tags
General Discussions
Asked by
kovyar
Top achievements
Rank 1
Answers by
Missing User
kovyar
Top achievements
Rank 1
Cody
Telerik team
Andrew
Top achievements
Rank 1
Veteran
Iron
Share this question
or