Skip to content

Commit c857966

Browse files
barancevdetro
authored andcommitted
Unifying use of waiting conditions
1 parent 62eec51 commit c857966

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

java/client/test/org/openqa/selenium/JavascriptEnabledDriverTest.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.openqa.selenium.testing.JUnit4TestBase;
2424
import org.openqa.selenium.testing.JavascriptEnabled;
2525

26-
import java.util.concurrent.Callable;
2726
import java.util.concurrent.TimeUnit;
2827

2928
import static org.hamcrest.Matchers.equalTo;
@@ -34,6 +33,7 @@
3433
import static org.junit.Assert.assertThat;
3534
import static org.junit.Assert.assertTrue;
3635
import static org.openqa.selenium.TestWaiter.waitFor;
36+
import static org.openqa.selenium.WaitingConditions.windowToBeSwitchedToWithName;
3737
import static org.openqa.selenium.WaitingConditions.elementTextToEqual;
3838
import static org.openqa.selenium.WaitingConditions.elementValueToEqual;
3939
import static org.openqa.selenium.testing.Ignore.Driver.ANDROID;
@@ -285,7 +285,7 @@ public void testShouldBeAbleToClickALinkThatClosesAWindow() throws Exception {
285285
driver.findElement(By.id("new_window")).click();
286286

287287
// Depending on the Android emulator platform this can take a while.
288-
waitFor(openAndSwitchToWindow("close_me", driver), 30, TimeUnit.SECONDS);
288+
waitFor(windowToBeSwitchedToWithName(driver, "close_me"), 30, TimeUnit.SECONDS);
289289

290290
driver.findElement(By.id("close")).click();
291291

@@ -294,15 +294,6 @@ public void testShouldBeAbleToClickALinkThatClosesAWindow() throws Exception {
294294
// If we haven't seen an exception or hung the test has passed
295295
}
296296

297-
private Callable<Boolean> openAndSwitchToWindow(final String name, final WebDriver driver) {
298-
return new Callable<Boolean>() {
299-
public Boolean call() throws Exception {
300-
driver.switchTo().window(name);
301-
return Boolean.TRUE;
302-
}
303-
};
304-
}
305-
306297
private void moveFocus() {
307298
driver.findElement(By.id("clickField")).click();
308299
}

0 commit comments

Comments
 (0)