[java] Let JUnit do its job
@@ -107,12 +107,9 @@ public void testShouldThrowIllegalArgumentExceptionWhenKeysNull() {
driver.findElement(By.id("alert")).click();
Alert alert = wait.until(alertIsPresent());
- try {
+
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> alert.sendKeys(null));
- } finally {
- alert.accept();
- }
}
@Test
@@ -138,11 +135,8 @@ public void testShouldGetTextOfAlertOpenedInSetTimeout() {
driver.findElement(By.id("slow-alert")).click();
Alert alert = wait.until(alertIsPresent());
- try {
+
assertThat(alert.getText()).isEqualTo("Slow");
- } finally {
- alert.accept();
- }
}
@Test
@@ -201,12 +195,8 @@ public void testSettingTheValueOfAnAlertThrows() {
driver.findElement(By.id("alert")).click();
Alert alert = wait.until(alertIsPresent());
- try {
assertThatExceptionOfType(ElementNotInteractableException.class)
.isThrownBy(() -> alert.sendKeys("cheese"));
- } finally {
- alert.accept();
- }
}
@Test
