I am working on test automation for a website.

Sometimes (note only sometimes), when I try to attach to a Window, the attach fails (usually the second time).

However, when I changed the attach to a HTMLBrowser it works fine everytime (atleast so far).

Is there any recommendation to attach only the browser instead of the window when testing websites?