Skip to content

Commit d778865

Browse files
Mikko Tiihonenshs96c
Mikko Tiihonen
authored andcommitted
Fix ExpectedConditions.not to use equals for Boolean comparisions to fix a bug where new Boolean(false) was not considered to equal to false
Signed-off-by: Simon Stewart <[email protected]>
1 parent 3800c43 commit d778865

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ public static ExpectedCondition<Boolean> not(final ExpectedCondition<?> conditio
859859
@Override
860860
public Boolean apply(WebDriver driver) {
861861
Object result = condition.apply(driver);
862-
return result == null || result == Boolean.FALSE;
862+
return result == null || result.equals(Boolean.FALSE);
863863
}
864864

865865
@Override

java/client/test/org/openqa/selenium/support/ui/ExpectedConditionsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public void waitingForVisibilityOfElementInverse_elementStaysVisible()
234234

235235
@Test
236236
public void invertingAConditionThatReturnsFalse() {
237-
when(mockCondition.apply(mockDriver)).thenReturn(false);
237+
when(mockCondition.apply(mockDriver)).thenReturn(new Boolean(false));
238238

239239
assertTrue(wait.until(not(mockCondition)));
240240
verifyZeroInteractions(mockSleeper);
@@ -252,7 +252,7 @@ public void invertingAConditionThatReturnsNull() {
252252
public void invertingAConditionThatAlwaysReturnsTrueTimesout() throws InterruptedException {
253253
when(mockClock.laterBy(1000L)).thenReturn(3000L);
254254
when(mockClock.isNowBefore(3000L)).thenReturn(true, false);
255-
when(mockCondition.apply(mockDriver)).thenReturn(true);
255+
when(mockCondition.apply(mockDriver)).thenReturn(new Boolean(true));
256256

257257
try {
258258
wait.until(not(mockCondition));

0 commit comments

Comments
 (0)