Skip to content

Commit 63f6282

Browse files
committed
refactor test
1 parent 7faa74b commit 63f6282

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/test/java/io/selenium/util/CachedLookupTest.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java.util.List;
1717

1818
import static org.junit.jupiter.api.Assertions.assertEquals;
19-
import static org.junit.jupiter.api.Assertions.fail;
19+
import static org.junit.jupiter.api.Assertions.assertThrows;
2020

2121

2222
public class CachedLookupTest {
@@ -54,16 +54,10 @@ public void checkCachedGroceryListItems() {
5454
firstItem.getRemoveButton().click();
5555
lastItem.getRemoveButton().click();
5656
assertEquals("Baking item2", item2.getName().getText());
57-
try {
58-
firstItem.getName().getText();
59-
fail("Should throw stale element reference exception");
60-
} catch (StaleElementReferenceException ignored) {
61-
}
62-
try {
63-
lastItem.getName().getText();
64-
fail("Should throw stale element reference exception");
65-
} catch (StaleElementReferenceException ignored) {
66-
}
57+
assertThrows(StaleElementReferenceException.class, () ->
58+
firstItem.getName().getText(), "Should throw stale element reference exception");
59+
assertThrows(StaleElementReferenceException.class, () ->
60+
lastItem.getName().getText(), "Should throw stale element reference exception");
6761
}
6862

6963
@Test

0 commit comments

Comments
 (0)