Skip to content

Commit 3ab59f8

Browse files
committed
Resolving bug #84
1 parent 3b77b4f commit 3ab59f8

File tree

2 files changed

+53
-56
lines changed

2 files changed

+53
-56
lines changed

src/test/java/uk/co/evoco/webdriver/configuration/utils/TolerantExceptionHandlerTests.java

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/test/java/uk/co/evoco/webdriver/utils/TolerantExceptionHandlerTests.java

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package uk.co.evoco.webdriver.utils;
22

33
import org.junit.jupiter.api.Test;
4+
import org.openqa.selenium.ElementClickInterceptedException;
45
import org.openqa.selenium.InvalidArgumentException;
6+
import org.openqa.selenium.StaleElementReferenceException;
57

68
import java.util.ArrayList;
79
import java.util.List;
810

9-
import static org.junit.jupiter.api.Assertions.assertEquals;
10-
import static org.junit.jupiter.api.Assertions.assertThrows;
11-
11+
import static org.junit.jupiter.api.Assertions.*;
12+
import static org.junit.jupiter.api.Assertions.fail;
1213

1314
public class TolerantExceptionHandlerTests {
1415

@@ -66,4 +67,53 @@ public void testIgnoresClassesInTolerantExceptionListThatAreNotThrowable () thro
6667
ArithmeticException inputException = new ArithmeticException();
6768
assertEquals(inputException, handler.propagateIfNotIgnored(inputException));
6869
}
70+
71+
@Test
72+
public void testShouldNotPropagateExceptionOnElementClickInterceptedException() throws Throwable {
73+
List<String> exceptions = new ArrayList<>();
74+
exceptions.add("ElementClickInterceptedException");
75+
TolerantExceptionHandler tolerantExceptionHandler = new TolerantExceptionHandler(exceptions);
76+
try {
77+
tolerantExceptionHandler.propagateIfNotIgnored(new ElementClickInterceptedException("Hello"));
78+
assertTrue(true);
79+
} catch(Exception e) {
80+
fail();
81+
}
82+
}
83+
84+
@Test
85+
public void testShouldNotPropagateExceptionOnStaleElementException() throws Throwable {
86+
List<String> exceptions = new ArrayList<>();
87+
exceptions.add("StaleElementReferenceException");
88+
TolerantExceptionHandler tolerantExceptionHandler = new TolerantExceptionHandler(exceptions);
89+
try {
90+
tolerantExceptionHandler.propagateIfNotIgnored(new StaleElementReferenceException("Hello"));
91+
assertTrue(true);
92+
} catch(Exception e) {
93+
fail();
94+
}
95+
}
96+
97+
@Test
98+
public void testShouldNotPropagateExceptionOnStaleElementExceptionWithPacakgeName() throws Throwable {
99+
List<String> exceptions = new ArrayList<>();
100+
exceptions.add("org.openqa.selenium.StaleElementReferenceException");
101+
TolerantExceptionHandler tolerantExceptionHandler = new TolerantExceptionHandler(exceptions);
102+
try {
103+
tolerantExceptionHandler.propagateIfNotIgnored(new StaleElementReferenceException("Hello"));
104+
assertTrue(true);
105+
} catch(Exception e) {
106+
fail();
107+
}
108+
}
109+
110+
@Test
111+
public void testShouldPropagateExceptionWhenUnToleratedExceptionDetected() throws Throwable {
112+
List<String> exceptions = new ArrayList<>();
113+
exceptions.add("StaleElementReferenceException");
114+
TolerantExceptionHandler tolerantExceptionHandler = new TolerantExceptionHandler(exceptions);
115+
assertThrows(Throwable.class, () -> {
116+
tolerantExceptionHandler.propagateIfNotIgnored(new Exception("Hello"));
117+
});
118+
}
69119
}

0 commit comments

Comments
 (0)