In thread WatiN in Visual Studio 2008 - second test method fails there is a good solution with IEStaticInstanceHelper (original answer Reusing an IE instance in VS test, sources), but when ClassCleanup fires it fails on AttachToIE. As result IEXPLORAR remain running.
What is the problem?
Of course it is possible to just kill the process like this:
// Id of IEXPLORAR
_ie.ProcessID
Process.GetProcessById(_processId).Kill();
this._ie = null;
But I don't really like this way...
Any ideas?
It fails because MSTest does the class cleanup in a multi-threaded apartment, even thought it runs individual tests in an STA. The way WaitN attaches to IE involves looking up COM objects that aren't thread safe, and aren't exposed to MTA.
Thanks for the process kill workaround, using that too now, although I'm using CloseMainWindow()
rather than Kill()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With