Skip to content

Commit

Permalink
Updating .NET bindings frames tests to be xonsistent with Java
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Oct 8, 2015
1 parent d9fe0c0 commit a1da99a
Showing 1 changed file with 58 additions and 24 deletions.
82 changes: 58 additions & 24 deletions dotnet/test/common/FrameSwitchingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,28 @@ public void ShouldNotAutomaticallySwitchFocusToAnIFrameWhenAPageContainingThemIs
Assert.IsNotNull(element);
}

[Test]
public void ShouldOpenPageWithBrokenFrameset()
{
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("framesetPage3.html");

IWebElement frame1 = driver.FindElement(By.Id("first"));
driver.SwitchTo().Frame(frame1);

driver.SwitchTo().DefaultContent();

IWebElement frame2 = driver.FindElement(By.Id("second"));

try
{
driver.SwitchTo().Frame(frame2);
}
catch (WebDriverException)
{
// IE9 can not switch to this broken frame - it has no window.
}
}

// ----------------------------------------------------------------------------------------------
//
// Tests that WebDriver can switch to frames as expected.
Expand Down Expand Up @@ -326,6 +348,16 @@ public void ShouldBeAbleToClickInAFrame()
Assert.AreEqual("Success!", GetTextOfGreetingElement());
}

[Test]
public void testShouldBeAbleToClickInAFrameThatRewritesTopWindowLocation()
{
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("click_tests/issue5237.html");
driver.SwitchTo().Frame("search");
driver.FindElement(By.Id("submit")).Click();
driver.SwitchTo().DefaultContent();
WaitFor(() => { return driver.Title == "Target page for issue 5237"; }, "Browser title was not 'Target page for issue 5237'");
}

[Test]
[IgnoreBrowser(Browser.HtmlUnit)]
public void ShouldBeAbleToClickInASubFrame()
Expand All @@ -344,23 +376,6 @@ public void ShouldBeAbleToClickInASubFrame()
Assert.AreEqual("Success!", driver.FindElement(By.Id("greeting")).Text);
}

[Test]
[NeedsFreshDriver(AfterTest = true)]
public void ClosingTheFinalBrowserWindowShouldNotCauseAnExceptionToBeThrown()
{
driver.Url = simpleTestPage;
driver.Close();
}

[Test]
public void ShouldBeAbleToFlipToAFrameIdentifiedByItsId()
{
driver.Url = framesetPage;

driver.SwitchTo().Frame("fifth");
driver.FindElement(By.Id("username"));
}

[Test]
public void ShouldBeAbleToFindElementsInIframesByXPath()
{
Expand All @@ -374,22 +389,24 @@ public void ShouldBeAbleToFindElementsInIframesByXPath()
}

[Test]
public void GetCurrentUrl()
public void GetCurrentUrlShouldReturnTopLevelBrowsingContextUrl()
{
driver.Url = framesetPage;
Assert.AreEqual(framesetPage, driver.Url);

driver.SwitchTo().Frame("second");
string url = EnvironmentManager.Instance.UrlBuilder.WhereIs("page/2");
Assert.AreEqual(url + "?title=Fish", driver.Url);
Assert.AreEqual(framesetPage, driver.Url);
}

url = EnvironmentManager.Instance.UrlBuilder.WhereIs("iframes.html");
[Test]
public void GetCurrentUrlShouldReturnTopLevelBrowsingContextUrlForIframes()
{
driver.Url = iframePage;
Assert.AreEqual(url, driver.Url);
Assert.AreEqual(iframePage, driver.Url);


url = EnvironmentManager.Instance.UrlBuilder.WhereIs("formPage.html");
driver.SwitchTo().Frame("iframe1");
Assert.AreEqual(url, driver.Url);
Assert.AreEqual(iframePage, driver.Url);
}

[Test]
Expand Down Expand Up @@ -484,6 +501,23 @@ public void JavaScriptShouldExecuteInTheContextOfTheCurrentFrame()
//
// ----------------------------------------------------------------------------------------------

[Test]
[NeedsFreshDriver(AfterTest = true)]
public void ClosingTheFinalBrowserWindowShouldNotCauseAnExceptionToBeThrown()
{
driver.Url = simpleTestPage;
driver.Close();
}

[Test]
public void ShouldBeAbleToFlipToAFrameIdentifiedByItsId()
{
driver.Url = framesetPage;

driver.SwitchTo().Frame("fifth");
driver.FindElement(By.Id("username"));
}

[Test]
public void ShouldBeAbleToSelectAFrameByName()
{
Expand Down

0 comments on commit a1da99a

Please sign in to comment.