0
私のテストでは、ユーザーがサイトにログインできるかどうかがチェックされます。 作品を警告するコードを書いたが、部分をcatch
に表示した。 try
とcatch
なしでアラートを書き込もうとしましたが、エラーが表示されます。アラートが表示されない
try
とcatch
を使用せずにアラートを書き込む方法と警告が表示されます(合格テスト)。
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for alert to be present (tried for 5 second(s) with 500 MILLISECONDS interval)
これは私のコードです:
public void getMessage() {
//Verify that is message preview
try {
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = driver.switchTo().alert();
System.out.println(alert.getText());
alert.accept();
Assert.assertTrue(alert.getText().contains("ERROR: Invalid login credentials."));
} catch (Exception e) {
System.out.println("Alert is not displayed");
}
質問は何ですか? – Andersson
私の推測では、アラートはHTMLのダイアログであり、JSのアラートではないということです。アラートがポップアップしたら、右クリックします。右クリックのコンテキストメニューが表示され、それをInspectすることができれば、HTMLベースでありアラートではありません。 – JeffC
はい、これはhtmlです。
エラー :ログイン資格情報が無効です。 –