@@ -175,7 +175,6 @@ public void ShouldThrowNoSuchWindowExceptionOnAnyElementOperationIfAWindowIsClos
175
175
[ NeedsFreshDriver ( BeforeTest = true , AfterTest = true ) ]
176
176
[ IgnoreBrowser ( Browser . IE ) ]
177
177
[ IgnoreBrowser ( Browser . Safari , "Hangs Safari driver" ) ]
178
- //[IgnoreBrowser(Browser.Firefox)]
179
178
public void ShouldBeAbleToIterateOverAllOpenWindows ( )
180
179
{
181
180
driver . Url = xhtmlTestPage ;
@@ -199,10 +198,12 @@ public void ShouldBeAbleToIterateOverAllOpenWindows()
199
198
}
200
199
201
200
[ Test ]
202
- [ IgnoreBrowser ( Browser . IE , "IE prompts with an alert when closing. Revisit when alert handling is done" ) ]
203
201
[ IgnoreBrowser ( Browser . Safari , "Hangs Safari driver" ) ]
204
202
public void ClickingOnAButtonThatClosesAnOpenWindowDoesNotCauseTheBrowserToHang ( )
205
203
{
204
+ bool isIEDriver = TestUtilities . IsInternetExplorer ( driver ) ;
205
+ bool isIE6 = TestUtilities . IsIE6 ( driver ) ;
206
+
206
207
driver . Url = xhtmlTestPage ;
207
208
208
209
String currentHandle = driver . CurrentWindowHandle ;
@@ -215,6 +216,11 @@ public void ClickingOnAButtonThatClosesAnOpenWindowDoesNotCauseTheBrowserToHang(
215
216
{
216
217
IWebElement closeElement = WaitFor ( ( ) => { return driver . FindElement ( By . Id ( "close" ) ) ; } ) ;
217
218
closeElement . Click ( ) ;
219
+ if ( isIEDriver && ! isIE6 )
220
+ {
221
+ IAlert alert = WaitFor < IAlert > ( AlertToBePresent ( ) ) ;
222
+ alert . Accept ( ) ;
223
+ }
218
224
// If we make it this far, we're all good.
219
225
}
220
226
finally
@@ -226,10 +232,12 @@ public void ClickingOnAButtonThatClosesAnOpenWindowDoesNotCauseTheBrowserToHang(
226
232
227
233
[ Test ]
228
234
[ Category ( "Javascript" ) ]
229
- [ IgnoreBrowser ( Browser . IE , "IE prompts with an alert when closing. Revisit when alert handling is done" ) ]
230
235
[ IgnoreBrowser ( Browser . Safari , "Hangs Safari driver" ) ]
231
236
public void CanCallGetWindowHandlesAfterClosingAWindow ( )
232
237
{
238
+ bool isIEDriver = TestUtilities . IsInternetExplorer ( driver ) ;
239
+ bool isIE6 = TestUtilities . IsIE6 ( driver ) ;
240
+
233
241
driver . Url = xhtmlTestPage ;
234
242
235
243
String currentHandle = driver . CurrentWindowHandle ;
@@ -242,6 +250,11 @@ public void CanCallGetWindowHandlesAfterClosingAWindow()
242
250
{
243
251
IWebElement closeElement = WaitFor ( ( ) => { return driver . FindElement ( By . Id ( "close" ) ) ; } ) ;
244
252
closeElement . Click ( ) ;
253
+ if ( isIEDriver && ! isIE6 )
254
+ {
255
+ IAlert alert = WaitFor < IAlert > ( AlertToBePresent ( ) ) ;
256
+ alert . Accept ( ) ;
257
+ }
245
258
ReadOnlyCollection < string > handles = driver . WindowHandles ;
246
259
// If we make it this far, we're all good.
247
260
}
@@ -413,5 +426,22 @@ private Func<bool> WindowWithName(string name)
413
426
return false ;
414
427
} ;
415
428
}
429
+
430
+ private Func < IAlert > AlertToBePresent ( )
431
+ {
432
+ return ( ) =>
433
+ {
434
+ IAlert alert = null ;
435
+ try
436
+ {
437
+ alert = driver . SwitchTo ( ) . Alert ( ) ;
438
+ }
439
+ catch ( NoAlertPresentException )
440
+ {
441
+ }
442
+
443
+ return alert ;
444
+ } ;
445
+ }
416
446
}
417
447
}
0 commit comments