10

断続的にブラウザー インスタンスにアタッチしようとすると、継続的インテグレーション ビルド プロセスの一部として実行される WatiN ステップが失敗します。現在5回に1回程度。

Browser.AttachTo<IE>(Find.ByTitle("Title of Popup"));

次のエラーが発生します。

WatiN.Core.Exceptions.TimeoutException: Timeout while Internet Explorer busy
   at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.ThrowTimeOutException(Exception lastException, String message)
   at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.HandleTimeOut()
   at WatiN.Core.UtilityClasses.TryFuncUntilTimeOut.Try[T](DoFunc`1 func)
   at WatiN.Core.WaitForCompleteBase.WaitUntil(DoFunc`1 waitWhile, BuildTimeOutExceptionMessage exceptionMessage)
   at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitUntilNotNull(DoFunc`1 func, BuildTimeOutExceptionMessage exceptionMessage)
   at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitWhileIEBusy(IWebBrowser2 ie)
   at WatiN.Core.Native.InternetExplorer.IEWaitForComplete.WaitForCompleteOrTimeout()
   at WatiN.Core.WaitForCompleteBase.DoWait()
   at WatiN.Core.Native.InternetExplorer.AttachToIeHelper.FinishInitializationAndWaitForComplete(IE ie, SimpleTimer timer, Boolean waitForComplete)
   at WatiN.Core.Native.InternetExplorer.AttachToIeHelper.Find(Constraint findBy, Int32 timeout, Boolean waitForComplete)
   at WatiN.Core.Browser.AttachTo[T](Constraint constraint)

以前の投稿で提案された明らかなことをすべて実行しました。

つまり、WatiN ステップを実行する前に、すべての Internet Explorer プロセスを強制終了します。

Process.GetProcessesByName("IEXPLORE").ToList().ForEach(p => p.Kill());

WatiN ステップを実行する前に、タイムアウトを増やします。

var timeout = 60;
Settings.AttachToBrowserTimeOut = timeout;
Settings.WaitForCompleteTimeOut = timeout;
Settings.WaitUntilExistsTimeOut = timeout;

各 WatiN ステップは、次のコード ブロックでアクションとして渡されます。

public void UseAndCloseBrowser(Action<Browser> action, Browser browser)
{
    try
    {
        action(browser);
        browser.WaitForComplete();
    }
    finally
    {
        Log(Level.Info, "Attempting to close browser {0}", browser.Title);
        browser.Close();
        browser.Dispose();
    }

}

この迷惑なエラーメッセージの最後にたどり着くために私ができること/確認できることを誰かが知っていますか?

4

1 に答える 1

1

過去に同様の問題がありましたが、解決策は、セッションごとに同じブラウザー ウィンドウを再利用することでした。最初のテストの実行時にブラウザ ウィンドウを作成し、それをすべてのテストに使用してから、必要に応じてテスト セッションの終了時に閉じます。明らかに、これは使用しているテスト ハーネスに依存しますが、動作するはずです。IE ウィンドウの作成と破棄はリソースを大量に消費するアクティビティであるため、可能であれば回避することをお勧めします。

于 2012-11-10T05:06:07.557 に答える