问题
When I run any WatiN test on Windows 7 with IE8(note that all tests pass on Vista with IE8), the browser displays the first page but does not go any further. The following exception is displayed after a few seconds:
WatiN.Core.Exceptions.TimeoutException: Timeout while Internet Explorer state not complete
at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.ThrowTimeOutException(Exception lastException, String message)
at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.HandleTimeOut()
at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.Try(DoFunc1 func)
at WatiN.Core.WaitForCompleteBase.WaitUntil(DoFunc
1 waitWhile, BuildTimeOutExceptionMessage exceptionMessage)
at WatiN.Core.Native.InternetExplorer.WaitForComplete.WaitWhileIEReadyStateNotComplete(IWebBrowser2 ie)
at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.DoWait()
at WatiN.Core.DomContainer.WaitForComplete(IWait waitForComplete)
at WatiN.Core.IE.WaitForComplete(Int32 waitForCompleteTimeOut)
at WatiN.Core.DomContainer.WaitForComplete()
at WatiN.Core.Browser.GoTo(Uri url)
at WatiN.Core.IE.FinishInitialization(Uri uri)
at WatiN.Core.IE.CreateNewIEAndGoToUri(Uri uri, IDialogHandler logonDialogHandler, Boolean createInNewProcess)
at WatiN.Core.IE..ctor(String url)
at CCS.iPS.ST.Tests.UIWithDBVerification.Tests.DCC_Offered_Completed_ThreeDS_And_Authorisation_Completed() in Tests.cs: line 18
回答1:
Make sure you are running as an Administrator. Seems to be an issue where Watin can't access the DOM in IE unless the application is running with System Administrator privileges.
回答2:
I know this is an ancient thread, but I've found found a workaround for WatiN under Windows 7 that doesn't require you to run as an administrator (which isn't allowed in my company :S) If you disable protected mode in Internet Explorer it should run fine: -
1 - Open internet explorer.
2 - Click on Tools menu and select Internet Options.
3 - Select Security Tab in the Internet options windows.
4 - Select Internet from the zone settings.
5 - Uncheck Enable Protected Mode option to disable the protection from Security for this zone.
6 - Hit Apply and Ok
来源:https://stackoverflow.com/questions/1999109/having-problems-running-watin-on-windows-7-with-ie-8