diff --git a/dotnet/test/common/FrameSwitchingTest.cs b/dotnet/test/common/FrameSwitchingTest.cs index 0e5962baa8cca..622dff3f2fbef 100644 --- a/dotnet/test/common/FrameSwitchingTest.cs +++ b/dotnet/test/common/FrameSwitchingTest.cs @@ -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. @@ -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() @@ -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() { @@ -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] @@ -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() {