Downloading files in IE7

19 posts, 0 answers
  1. kovyar
    kovyar avatar
    42 posts
    Member since:
    Jul 2010

    Posted 29 Jul 2010 Link to this post

    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

  2. Missing user
    Missing user avatar

    Posted 30 Jul 2010 Link to this post

    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
  3. kovyar
    kovyar avatar
    42 posts
    Member since:
    Jul 2010

    Posted 31 Jul 2010 Link to this post

    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

  4. kovyar
    kovyar avatar
    42 posts
    Member since:
    Jul 2010

    Posted 02 Aug 2010 Link to this post

    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
  5. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 02 Aug 2010 Link to this post

    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
  6. kovyar
    kovyar avatar
    42 posts
    Member since:
    Jul 2010

    Posted 02 Aug 2010 Link to this post

    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

  7. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 02 Aug 2010 Link to this post

    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
  8. kovyar
    kovyar avatar
    42 posts
    Member since:
    Jul 2010

    Posted 02 Aug 2010 Link to this post

    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

  9. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 02 Aug 2010 Link to this post

    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
  10. kovyar
    kovyar avatar
    42 posts
    Member since:
    Jul 2010

    Posted 03 Aug 2010 Link to this post

    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
  11. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 03 Aug 2010 Link to this post

    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
  12. Andrew
    Andrew avatar
    125 posts
    Member since:
    Sep 2008

    Posted 06 Oct 2010 Link to this post

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





  13. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 06 Oct 2010 Link to this post

    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
  14. Andrew
    Andrew avatar
    125 posts
    Member since:
    Sep 2008

    Posted 06 Oct 2010 Link to this post

    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
  15. Andrew
    Andrew avatar
    125 posts
    Member since:
    Sep 2008

    Posted 06 Oct 2010 Link to this post

    the window in the screen shot is just a panel controedl by a ModalPopupExtender (see the html markup I included)
  16. Andrew
    Andrew avatar
    125 posts
    Member since:
    Sep 2008

    Posted 06 Oct 2010 Link to this post

    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)
  17. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 06 Oct 2010 Link to this post

    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
  18. Andrew
    Andrew avatar
    125 posts
    Member since:
    Sep 2008

    Posted 07 Oct 2010 Link to this post

    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 + "'");
                    }
      
                }
  19. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 12 Oct 2010 Link to this post

    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
Back to Top