Skip to content

Commit a1da99a

Browse files
committed
Updating .NET bindings frames tests to be xonsistent with Java
1 parent d9fe0c0 commit a1da99a

File tree

1 file changed

+58
-24
lines changed

1 file changed

+58
-24
lines changed

dotnet/test/common/FrameSwitchingTest.cs

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,28 @@ public void ShouldNotAutomaticallySwitchFocusToAnIFrameWhenAPageContainingThemIs
3131
Assert.IsNotNull(element);
3232
}
3333

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+
3456
// ----------------------------------------------------------------------------------------------
3557
//
3658
// Tests that WebDriver can switch to frames as expected.
@@ -326,6 +348,16 @@ public void ShouldBeAbleToClickInAFrame()
326348
Assert.AreEqual("Success!", GetTextOfGreetingElement());
327349
}
328350

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+
329361
[Test]
330362
[IgnoreBrowser(Browser.HtmlUnit)]
331363
public void ShouldBeAbleToClickInASubFrame()
@@ -344,23 +376,6 @@ public void ShouldBeAbleToClickInASubFrame()
344376
Assert.AreEqual("Success!", driver.FindElement(By.Id("greeting")).Text);
345377
}
346378

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-
364379
[Test]
365380
public void ShouldBeAbleToFindElementsInIframesByXPath()
366381
{
@@ -374,22 +389,24 @@ public void ShouldBeAbleToFindElementsInIframesByXPath()
374389
}
375390

376391
[Test]
377-
public void GetCurrentUrl()
392+
public void GetCurrentUrlShouldReturnTopLevelBrowsingContextUrl()
378393
{
379394
driver.Url = framesetPage;
395+
Assert.AreEqual(framesetPage, driver.Url);
380396

381397
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+
}
384400

385-
url = EnvironmentManager.Instance.UrlBuilder.WhereIs("iframes.html");
401+
[Test]
402+
public void GetCurrentUrlShouldReturnTopLevelBrowsingContextUrlForIframes()
403+
{
386404
driver.Url = iframePage;
387-
Assert.AreEqual(url, driver.Url);
405+
Assert.AreEqual(iframePage, driver.Url);
388406

389407

390-
url = EnvironmentManager.Instance.UrlBuilder.WhereIs("formPage.html");
391408
driver.SwitchTo().Frame("iframe1");
392-
Assert.AreEqual(url, driver.Url);
409+
Assert.AreEqual(iframePage, driver.Url);
393410
}
394411

395412
[Test]
@@ -484,6 +501,23 @@ public void JavaScriptShouldExecuteInTheContextOfTheCurrentFrame()
484501
//
485502
// ----------------------------------------------------------------------------------------------
486503

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+
487521
[Test]
488522
public void ShouldBeAbleToSelectAFrameByName()
489523
{

0 commit comments

Comments
 (0)