JUnit で Webdriver Backed Selenium を使用して確認ポップアップをテストしようとすると、奇妙な動作に関連する問題が発生します。
私のテストケースには、次のコードのチャンクがあります。
assertTrue(isElementPresent(By.xpath("//input[@title='Delete Site']")));
selenium().click("//input[@title='Delete Site']");
//assertTrue(selenium().isConfirmationPresent());
//assertEquals(selenium().getConfirmation(), "Are you sure want to delete this item?");
selenium().waitForPageToLoad("30000");
上記の行は、次の要素を参照しています。
<input onclick="return confirm('Are you sure want to delete this item?');" value="Delete Site" type="image" title="Delete Site" src="/workthru-web/resources/images/delete.png" class="image" alt="Delete Site">
ただし、コメント行でテストは失敗します。同じことを手動で行うと、期待どおりにプロンプトが表示されます。WebDriver の実行時にポップアップ ウィンドウが無効になる可能性はありますか? を使用してドライバーを作成しますnew FirefoxDriver()
。余分なパラメーターはありません。追加の構成が必要ですか? それとも、ここで何か他のものを見逃していますか?