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 8838671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:03:50+00:00 2026-06-14T10:03:50+00:00

I am using Watin 2.1 to try to test file download and file open

  • 0

I am using Watin 2.1 to try to test file download and file open functionality for a website.
This worked well in Internet Explorer 8, but since Internet Explorer 9 there is a yellow-white download bar at the bottom of the view instead of a popup dialog window.

I found this answer:
https://stackoverflow.com/a/8532222/246622, which solves that problem, as long as the browser tab that I am interested in is on top.
If there are other tabs that are on top, it cannot not find the download bar.
The problem here is that these tests will open other tabs on top of the tab with the download bar, before the download starts.

So, how do I access the correct tab, or how do I switch the top/visible tab in internet explorer, or how do I get those other pages to open in other windows instead of in tabs in the same window, or how do I close those other tabs from my test application?

Here is the relevant piece of code:

Window windowMain = new Window(WatiN.Core.Native.Windows.NativeMethods.GetWindow(browser.hWnd, 5/*GW_CHILD*/)); // This gets the topmost browser tab.
System.Windows.Automation.TreeWalker trw = new System.Windows.Automation.TreeWalker(System.Windows.Automation.Condition.TrueCondition);
mainWindow = trw.GetParent(System.Windows.Automation.AutomationElement.FromHandle(browser.hWnd));
windowDialog = new Window(WatiN.Core.Native.Windows.NativeMethods.GetWindow(windowMain.Hwnd, 5));

I tried this:

var lowerWindow = new Window(WatiN.Core.Native.Windows.NativeMethods.GetWindow(aBrowserTab.Hwnd, 2/*GW_HWNDNEXT*/)); // This gets a next lower window.

I was then planning on identifying the correct tab using a regex with the title:

titleRegex.IsMatch(windowMain.ToplevelWindow.Title)

but this gets a lower window instead of a lower tab in the same window.

  • 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-06-14T10:03:52+00:00Added an answer on June 14, 2026 at 10:03 am

    I had a similar problem and after investigations similar to what you are trying I decided to try alternative routes. Also note that even if you do get it right like this, you’ll have a lot of work to port your tests on other browsers and IE 10 is coming out fast.

    1. Do you really need to download the file from the browser? How about – read the URL that triggers the download and then do a WebRequest on that URL to retrieve your file?

    2. Look at using Coded UI – not the recorded tests but the generated ones. They are able to automate clicking on window apps as well as within the browser. Also note that development does seem to have stopped on waitn so it might make sense to move to something more reliable.

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

Sidebar

Related Questions

I'm using Watin to automate download file from a website. At some point a
I am trying to run tests using WatiN with Internet Explorer 9, and my environment won't
I want to test a popped up page using watin, but can't find any
I am currently using WatiN to automate a proprietary website at my work, and
I'm trying to upload a file using Watin and C#. Under Windows XP, Watin
I am using WatiN (2.0.10.928) with C# and Visual Studio 2008 to test a
I am trying to attach Watin to an existing instance of Internet Explorer 9.
I'm trying to parse a webpage using open-uri + hpricot but it seems to
We are using WatiN - 2.1.0 to take a screenshot when an integration test
When I try to run a WatIn test trough the NUnit ide, I get

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.