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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:02:34+00:00 2026-05-18T05:02:34+00:00

I am experimenting with WatiN for our UI testing, I can get tests to

  • 0

I am experimenting with WatiN for our UI testing, I can get tests to work, but I can’t get IE to close afterwards.

I’m trying to close IE in my class clean up code, using WatiN’s example IEStaticInstanceHelper technique.

The problem seems to be attaching to the IE thread, which times out:

_instance = IE.AttachTo<IE>(Find.By("hwnd", _ieHwnd));

(_ieHwnd is the handle to IE stored when IE is first launched.)

This gives the error:

Class Cleanup method
Class1.MyClassCleanup failed. Error
Message:
WatiN.Core.Exceptions.BrowserNotFoundException:
Could not find an IE window matching
constraint: Attribute ‘hwnd’ equals
‘1576084’. Search expired after ’30’
seconds.. Stack Trace: at
WatiN.Core.Native.InternetExplorer.AttachToIeHelper.Find(Constraint
findBy, Int32 timeout, Boolean
waitForComplete)

I’m sure I must be missing something obvious, has anyone got any ideas about this one?
Thanks

For completeness, the static helper looks like this:

public class StaticBrowser
{
    private IE _instance;
    private int _ieThread;
    private string _ieHwnd;

    public IE Instance
    {
        get
        {
            var currentThreadId = GetCurrentThreadId();
            if (currentThreadId != _ieThread)
            {
                _instance = IE.AttachTo<IE>(Find.By("hwnd", _ieHwnd));
                _ieThread = currentThreadId;
            }
            return _instance;
        }
        set
        {
            _instance = value;
            _ieHwnd = _instance.hWnd.ToString();
            _ieThread = GetCurrentThreadId();
        }
    }

private int GetCurrentThreadId()
{
    return Thread.CurrentThread.GetHashCode();
}
    }

And the clean up code looks like this:

private static StaticBrowser _staticBrowser;

[ClassCleanup]
public static void MyClassCleanup()
{
    _staticBrowser.Instance.Close();
    _staticBrowser = null;
}
  • 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-18T05:02:35+00:00Added an answer on May 18, 2026 at 5:02 am

    Fixed this myself by dumping mstest and using mbunit instead. I also found that I didn’t need to use any of the IEStaticInstanceHelper stuff either, it just worked.

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

Sidebar

Related Questions

I experimenting with jQuery. As I was trying I found out that I can't
Experimenting with Scala... I'm trying to define something analogous to the @ hack in
Experimenting using different approaches and reducing code maintenance I have ended up using reflection
Experimenting with existential types. Seems to be a great way to get some type
After experimenting with an iterator block I noticed the generated IL code is not
I am doing some experimenting (so the code below has lots of stuff that
I'm experimenting with the Doctrine ORM (v1.2) for PHP. I have defined a class
In experimenting with pickle, I've put together some code for a (very) simple blog.
Experimenting with jQuery and trying to make a small slide show that rotates through
Im experimenting with the following code private void timer1_Tick(object sender, EventArgs e) { Thread

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.