From fb249b3d0be0607a3c0a4ea2f1f2ba9c7a136e05 Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Tue, 23 Oct 2018 15:07:29 +0300 Subject: [PATCH] [java] Let JUnit do its job --- .../test/org/openqa/selenium/AlertsTest.java | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/java/client/test/org/openqa/selenium/AlertsTest.java b/java/client/test/org/openqa/selenium/AlertsTest.java index 835f1b4e73c19..41bed1b87260d 100644 --- a/java/client/test/org/openqa/selenium/AlertsTest.java +++ b/java/client/test/org/openqa/selenium/AlertsTest.java @@ -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(); - } + + assertThatExceptionOfType(IllegalArgumentException.class) + .isThrownBy(() -> alert.sendKeys(null)); } @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(); - } + + assertThat(alert.getText()).isEqualTo("Slow"); } @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(); - } + assertThatExceptionOfType(ElementNotInteractableException.class) + .isThrownBy(() -> alert.sendKeys("cheese")); } @Test