Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6562083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:40:02+00:00 2026-05-25T13:40:02+00:00

I’m just getting started with WatiN and attempting to test a large number of

  • 0

I’m just getting started with WatiN and attempting to test a large number of pages with authentication. I’ve taken the approach of only creating a new instance of IE each time new login details are required. Once authenticated, the framework needs to navigate to 2 pages on the site and click a link on each to download a file (repeated multiple times within one authenticated session for different clients).

Navigating to the pages is fine and the download is working with IE9 using a combination of WatiN and SendKeys(). However, when it navigates to the second page and attempts to find the Link object by Text (which has the same text as on the previous page) it returns the download URL from the first page. This means that essentially whatever page I direct WatiN to, it still seems to be persisting the Link object from the first page.

The first method creates my browser object and returns it to the parent class:

public IE CreateBrowser(string email, string password, string loginUrl)
        {
            Settings.MakeNewIe8InstanceNoMerge = true;
            Settings.AutoCloseDialogs = true;
            IE ie = new IE(loginUrl);
            ie.TextField(Find.ById("Email")).TypeText(email);
            ie.TextField(Find.ById("Password")).TypeText(password);
            ie.Button(Find.ById("btnLogin")).Click();

            Thread.Sleep(1500);

            return ie;
        }

I then iterate through logins, passing the URL for each required page to the following:

public void DownloadFile(IE ie, string url)
        {
            //ie.NativeBrowser.NavigateTo(new Uri(url));
            ie.GoTo(url);
            Thread.Sleep(1000);

            //TODO: Why is link holding on to old object?
            Link lnk = null;
            lnk = ie.Link(Find.ByText("Download file"));
            lnk.WaitUntilExists();
            lnk.Focus();
            lnk.Click();

            //Pause to allow IE file dialog box to show
            Thread.Sleep(2000);

            //Alt + S to save
            SendKeys.SendWait("%(S)");
        }

The calling method ties it all together like so (I’ve obfuscated some of the details):

for (int i = 0; i < loginCount; i++)
{
    using (IE ie = HelperClass.CreateBrowser(lLogins[i].Email, lLogins[i].Password, ConfigurationManager.AppSettings["loginUrl"]))
    {
        ...Gets list of clients we're wanting to check

        for (int j = 0; j < clientCount; j++)
        {
            string url = "";

            switch ()
            {
                case "Page1":
                    string startDate = "20110831";
                    string endDate = "20110901";

                    url = String.Format(page1BaseUrl, HttpUtility.UrlEncode(lClients[j].Name), startDate, endDate);
                    break;

                case "Page2":
                    url = String.Format(page2BaseUrl, HttpUtility.UrlEncode(lClients[j].Name));
                    break;
            }

            HelperClass.DownloadFile(ie, url);
        }
    }
}

Does anyone have any idea what could be causing this or how to get around it? Do I need to create a new IE object for each request?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:40:03+00:00Added an answer on May 25, 2026 at 1:40 pm

    Okay, so I’ve managed to find out what was causing my Link object (and the parent Page object) to persist across multiple URLs.

    It seems that because I’m clicking the Link which forces the “Save As” box in IE9, this keeps the Page object current, even as the browser runs through all the other URLs in the background. This seems to update the HTML rendered in the window but not release the existing Page object (or possibly creates additional Page objects in memory).

    Because I’m using SendKeys() to hit the “Save” button, rather than a handled dialog in WatiN, the dialog stays open and persists the Page object.

    From the looks of things, I need to find a different, handled way of performing my file downloads/saving.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.