WatiN downloading a file from webpage

Posted by user541597 on Stack Overflow See other posts from Stack Overflow or by user541597
Published on 2012-10-25T04:05:56Z Indexed on 2012/10/25 5:00 UTC
Read the original article Hit count: 188

Filed under:
|

I have the following code which does a couple of webpage redirections and then clicks an tag which has a javascript fuction as the href. When it is called a file is download. My problem is I want to be able to download the file without being prompted to cancel, save or open. Please help I am using IE9

using (var browser = new IE("http:url.aspx")) {
    browser.TextField(Find.ByName("ctl00$ContentPlaceHolder1$Login1$UserName")).TypeText("cpereyra");
    browser.TextField(Find.ByName("ctl00$ContentPlaceHolder1$Login1$Password")).TypeText("Maxipereyra15");

    browser.Button(Find.ByName("ctl00$ContentPlaceHolder1$Login1$LoginButton")).Click();


    browser.GoTo("http://it-motivity-cmc/Movation/MyPage/MyDashboard.aspx?dynamicdashboardid=ab000000-7dea-11c9-b596-d01e04bebb94");

    while (browser.Eval("document.readyState") != "complete") {
        Thread.Sleep(1000); 
    }

    Div div = browser.Div("ctl00_ContentPlaceHolder1_wrapper_vis_zone1_1");
    div.Link(link => link.Text == "Export to CSV").Click();
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about watin