ModalDialogウィンドウを使用する古いアプリケーション用のSeleniumテストを記述します。私は1つModalDialogで処理する方法を知っている:Seleniumで複数のmodalDialogを処理できますか?
ModalDialogを開く前に、私は、これはJS呼び出す - 古典的な窓に窓プロModalDialogを変更するには:私はそれに切り替えるModalDialog開いた後
((IJavaScriptExecutor) _driver).ExecuteScript("window.showModalDialog = window.open;");
窓と私はそれを扱うことができます:
public static void SwitchToWindow(IWebDriver _driver, string url) { String parentWindowHandle = _driver.CurrentWindowHandle; IWebDriver popup = null; var windowIterator = _driver.WindowHandles; foreach (var windowHandle in windowIterator) { popup = _driver.SwitchTo().Window(windowHandle); if (popup.Url.Contains(url)) { break; } } }
しかし、私は二ModalDialog(私は今、第三のウィンドウにしています)で、私はこの問題を得たことをやりたい場合:
threw exception: OpenQA.Selenium.NoSuchElementException: Could not find element by: By.Id: btnClearSearchName
(Firefoxウィンドウに点滅している:送信要求には、何かを転送する、何かを読む)ので、ページが読み込まれていないため、Selenium cantが要素を見つけることはできません。
そして、私は前にJSエグゼキュータせずに第三のウィンドウを開こうとした場合、それはこのエラーを示しています
threw exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://localhost:7057/hub/session/c7e75043-9605-4f7c-80ac-233803527709/element/%7B7664f1ae-9c42-4de6-9e16-34fede6a9e26%7D/click timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out at System.Net.HttpWebRequest.GetResponse()
私は、Firefox 45.6.0とセレンV3.0.1を使用します。
ありがとうございました!
でデフォルトのコンテンツにバックフォーカス切り替えてください次のウィンドウを処理できるようにするには? 今、私は最初のそれは次のようになり、モーダル: 1.変更をモーダルにウィンドウにJSExecutorで(今ので1の窓)新しいウィンドウ ---- へ 3.スイッチをモーダルを開くために 2.クリック2番目のモーダル: - (もしJSExecutor = 2番目のモーダルが開かない場合) - 私はJSExecutorを試して、2番目のmodalWindowを直接開いていないと、エラーをタイムアウトします – emboe
私は 'break; 1つは 'else'ブロックです。 – Andersson
2番目のウィンドウの前にJSExecutorで同じエラーが発生します.JSExcecutorウィンドウを処理できないため、ウィンドウと点滅要求を開かない... – emboe