@@ -31,6 +31,28 @@ public void ShouldNotAutomaticallySwitchFocusToAnIFrameWhenAPageContainingThemIs
31
31
Assert . IsNotNull ( element ) ;
32
32
}
33
33
34
+ [ Test ]
35
+ public void ShouldOpenPageWithBrokenFrameset ( )
36
+ {
37
+ driver . Url = EnvironmentManager . Instance . UrlBuilder . WhereIs ( "framesetPage3.html" ) ;
38
+
39
+ IWebElement frame1 = driver . FindElement ( By . Id ( "first" ) ) ;
40
+ driver . SwitchTo ( ) . Frame ( frame1 ) ;
41
+
42
+ driver . SwitchTo ( ) . DefaultContent ( ) ;
43
+
44
+ IWebElement frame2 = driver . FindElement ( By . Id ( "second" ) ) ;
45
+
46
+ try
47
+ {
48
+ driver . SwitchTo ( ) . Frame ( frame2 ) ;
49
+ }
50
+ catch ( WebDriverException )
51
+ {
52
+ // IE9 can not switch to this broken frame - it has no window.
53
+ }
54
+ }
55
+
34
56
// ----------------------------------------------------------------------------------------------
35
57
//
36
58
// Tests that WebDriver can switch to frames as expected.
@@ -326,6 +348,16 @@ public void ShouldBeAbleToClickInAFrame()
326
348
Assert . AreEqual ( "Success!" , GetTextOfGreetingElement ( ) ) ;
327
349
}
328
350
351
+ [ Test ]
352
+ public void testShouldBeAbleToClickInAFrameThatRewritesTopWindowLocation ( )
353
+ {
354
+ driver . Url = EnvironmentManager . Instance . UrlBuilder . WhereIs ( "click_tests/issue5237.html" ) ;
355
+ driver . SwitchTo ( ) . Frame ( "search" ) ;
356
+ driver . FindElement ( By . Id ( "submit" ) ) . Click ( ) ;
357
+ driver . SwitchTo ( ) . DefaultContent ( ) ;
358
+ WaitFor ( ( ) => { return driver . Title == "Target page for issue 5237" ; } , "Browser title was not 'Target page for issue 5237'" ) ;
359
+ }
360
+
329
361
[ Test ]
330
362
[ IgnoreBrowser ( Browser . HtmlUnit ) ]
331
363
public void ShouldBeAbleToClickInASubFrame ( )
@@ -344,23 +376,6 @@ public void ShouldBeAbleToClickInASubFrame()
344
376
Assert . AreEqual ( "Success!" , driver . FindElement ( By . Id ( "greeting" ) ) . Text ) ;
345
377
}
346
378
347
- [ Test ]
348
- [ NeedsFreshDriver ( AfterTest = true ) ]
349
- public void ClosingTheFinalBrowserWindowShouldNotCauseAnExceptionToBeThrown ( )
350
- {
351
- driver . Url = simpleTestPage ;
352
- driver . Close ( ) ;
353
- }
354
-
355
- [ Test ]
356
- public void ShouldBeAbleToFlipToAFrameIdentifiedByItsId ( )
357
- {
358
- driver . Url = framesetPage ;
359
-
360
- driver . SwitchTo ( ) . Frame ( "fifth" ) ;
361
- driver . FindElement ( By . Id ( "username" ) ) ;
362
- }
363
-
364
379
[ Test ]
365
380
public void ShouldBeAbleToFindElementsInIframesByXPath ( )
366
381
{
@@ -374,22 +389,24 @@ public void ShouldBeAbleToFindElementsInIframesByXPath()
374
389
}
375
390
376
391
[ Test ]
377
- public void GetCurrentUrl ( )
392
+ public void GetCurrentUrlShouldReturnTopLevelBrowsingContextUrl ( )
378
393
{
379
394
driver . Url = framesetPage ;
395
+ Assert . AreEqual ( framesetPage , driver . Url ) ;
380
396
381
397
driver . SwitchTo ( ) . Frame ( "second" ) ;
382
- string url = EnvironmentManager . Instance . UrlBuilder . WhereIs ( "page/2" ) ;
383
- Assert . AreEqual ( url + "?title=Fish" , driver . Url ) ;
398
+ Assert . AreEqual ( framesetPage , driver . Url ) ;
399
+ }
384
400
385
- url = EnvironmentManager . Instance . UrlBuilder . WhereIs ( "iframes.html" ) ;
401
+ [ Test ]
402
+ public void GetCurrentUrlShouldReturnTopLevelBrowsingContextUrlForIframes ( )
403
+ {
386
404
driver . Url = iframePage ;
387
- Assert . AreEqual ( url , driver . Url ) ;
405
+ Assert . AreEqual ( iframePage , driver . Url ) ;
388
406
389
407
390
- url = EnvironmentManager . Instance . UrlBuilder . WhereIs ( "formPage.html" ) ;
391
408
driver . SwitchTo ( ) . Frame ( "iframe1" ) ;
392
- Assert . AreEqual ( url , driver . Url ) ;
409
+ Assert . AreEqual ( iframePage , driver . Url ) ;
393
410
}
394
411
395
412
[ Test ]
@@ -484,6 +501,23 @@ public void JavaScriptShouldExecuteInTheContextOfTheCurrentFrame()
484
501
//
485
502
// ----------------------------------------------------------------------------------------------
486
503
504
+ [ Test ]
505
+ [ NeedsFreshDriver ( AfterTest = true ) ]
506
+ public void ClosingTheFinalBrowserWindowShouldNotCauseAnExceptionToBeThrown ( )
507
+ {
508
+ driver . Url = simpleTestPage ;
509
+ driver . Close ( ) ;
510
+ }
511
+
512
+ [ Test ]
513
+ public void ShouldBeAbleToFlipToAFrameIdentifiedByItsId ( )
514
+ {
515
+ driver . Url = framesetPage ;
516
+
517
+ driver . SwitchTo ( ) . Frame ( "fifth" ) ;
518
+ driver . FindElement ( By . Id ( "username" ) ) ;
519
+ }
520
+
487
521
[ Test ]
488
522
public void ShouldBeAbleToSelectAFrameByName ( )
489
523
{
0 commit comments