问题
On WatiN UI tests, I'm having an issue where when running tests, an error will sometimes will throw the following error:
InvalidCastException was unhandled by user code" ... "Unable to cast COM object of type 'mshtml.HTMLDocumentClass' to interface type 'mshtml.IHTMLDocument2'. This operation failed because the QueryInterface call on the COM component for the interface with IID" ... "failed due to the following error. No such interface supported".
It doesn't appear to matter whether WatiN is finding an element on a page, or interacting with it (clicking or using the Eval method).
The errors happen on a frequency anywhere between all the time to some of the time. It's very inconsistent. It usually has a tendency to affect some elements more than others (in my case I had Javascript drop-down menus where it appeared to happen more often), but the error seems to be able to crop up almost anywhere.
Anyone experienced this, or have any ideas of how this issue might be solved?
Thanks
来源:https://stackoverflow.com/questions/11540886/randomly-throwing-invalidcastexception-during-tests