2323import org .openqa .selenium .testing .JUnit4TestBase ;
2424import org .openqa .selenium .testing .JavascriptEnabled ;
2525
26- import java .util .concurrent .Callable ;
2726import java .util .concurrent .TimeUnit ;
2827
2928import static org .hamcrest .Matchers .equalTo ;
3433import static org .junit .Assert .assertThat ;
3534import static org .junit .Assert .assertTrue ;
3635import static org .openqa .selenium .TestWaiter .waitFor ;
36+ import static org .openqa .selenium .WaitingConditions .windowToBeSwitchedToWithName ;
3737import static org .openqa .selenium .WaitingConditions .elementTextToEqual ;
3838import static org .openqa .selenium .WaitingConditions .elementValueToEqual ;
3939import 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