Modified:
/trunk/common/src/csharp/webdriver-common/ITargetLocator.cs
/trunk/common/test/csharp/webdriver-common-test/FrameSwitchingTest.cs
/trunk/common/test/csharp/webdriver-common-test/PageLoadingTest.cs
/trunk/common/test/csharp/webdriver-common-test/TargetLocatorTest.cs
/trunk/jobbie/src/csharp/webdriver-ie/IE/InternetExplorerDriver.cs
/trunk/remote/client/src/csharp/webdriver-remote-client/RemoteWebDriver.cs
=======================================
--- /trunk/common/src/csharp/webdriver-common/ITargetLocator.cs Thu Jan 7
11:34:14 2010
+++ /trunk/common/src/csharp/webdriver-common/ITargetLocator.cs Thu Dec 9
11:38:46 2010
@@ -33,12 +33,6 @@
/// <param name="frameIndex">The zero-based index of the frame to
select.</param>
/// <returns>An <see cref="IWebDriver"/> instance focused on the
specified frame.</returns>
/// <exception cref="NoSuchFrameException">If the frame cannot be
found.</exception>
- /// <remarks>The <see cref="Frame(System.Int32)"/> method finds
frames by numeric index,
- /// and the index is zero-based.That is, if a page has three
frames, the first frame
- /// would be at index "0", the second at index "1" and the third
at index "2". Once
- /// the frame has been selected, all subsequent calls on the
IWebDriver interface are
- /// made to that frame.
- /// </remarks>
IWebDriver Frame(int frameIndex);
/// <summary>
@@ -47,14 +41,17 @@
/// <param name="frameName">The name of the frame to
select.</param>
/// <returns>An <see cref="IWebDriver"/> instance focused on the
specified frame.</returns>
/// <exception cref="NoSuchFrameException">If the frame cannot be
found.</exception>
- /// <remarks>The <see cref="Frame(System.String)"/> method selects
a frame by its
- /// name or ID. To select sub-frames, simply separate the frame
names/IDs by dots.
- /// As an example "main.child" will select the frame with the
name "main" and then
- /// it's child "child". If a frame name is a number, then it will
be treated as
- /// selecting a frame as if using <see
cref="Frame(System.Int32)"/>.
- /// </remarks>
IWebDriver Frame(string frameName);
+ /// <summary>
+ /// Select a frame using its previously located <see
cref="IWebElement"/>
+ /// </summary>
+ /// <param name="frameElement">The frame element to switch
to.</param>
+ /// <returns>An <see cref="IWebDriver"/> instance focused on the
specified frame.</returns>
+ /// <exception cref="NoSuchFrameException">If the element is
neither a FRAME nor an IFRAME element.</exception>
+ /// <exception cref="StaleElementReferenceException">If the
element is no longer valid.</exception>
+ IWebDriver Frame(IWebElement frameElement);
+
/// <summary>
/// Switches the focus of future commands for this driver to the
window with the given name.
/// </summary>
=======================================
--- /trunk/common/test/csharp/webdriver-common-test/FrameSwitchingTest.cs
Fri Oct 8 11:56:39 2010
+++ /trunk/common/test/csharp/webdriver-common-test/FrameSwitchingTest.cs
Thu Dec 9 11:38:46 2010
@@ -7,228 +7,296 @@
[TestFixture]
public class FrameSwitchingTest : DriverTestFixture
{
+ //
----------------------------------------------------------------------------------------------
+ //
+ // Tests that WebDriver doesn't do anything fishy when it
navigates to a page with frames.
+ //
+ //
----------------------------------------------------------------------------------------------
+
[Test]
- public void
ShouldContinueToReferToTheSameFrameOnceItHasBeenSelected()
+ public void
ShouldAlwaysFocusOnTheTopMostFrameAfterANavigationEvent()
{
driver.Url = framesetPage;
-
- driver.SwitchTo().Frame(2);
- IWebElement checkbox =
driver.FindElement(By.XPath("//input[@name='checky']"));
- checkbox.Toggle();
- checkbox.Submit();
-
-
Assert.AreEqual(driver.FindElement(By.XPath("//p")).Text, "Success!");
+ IWebElement element =
driver.FindElement(By.TagName("frameset"));
+ Assert.IsNotNull(element);
}
[Test]
- public void ShouldAutomaticallyUseTheFirstFrameOnAPage()
- {
- driver.Url = framesetPage;
-
- // Notice that we've not switched to the 0th frame
- IWebElement pageNumber =
driver.FindElement(By.XPath("//span[@id='pageNumber']"));
- Assert.AreEqual(pageNumber.Text.Trim(), "1");
- }
+ public void
ShouldNotAutomaticallySwitchFocusToAnIFrameWhenAPageContainingThemIsLoaded()
+ {
+ driver.Url = iframePage;
+
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
+ IWebElement element =
driver.FindElement(By.Id("iframe_page_heading"));
+ Assert.IsNotNull(element);
+ }
+
+ //
----------------------------------------------------------------------------------------------
+ //
+ // Tests that WebDriver can switch to frames as expected.
+ //
+ //
----------------------------------------------------------------------------------------------
[Test]
- public void
ShouldFocusOnTheReplacementWhenAFrameFollowsALinkToA_TopTargettedPage()
+ public void ShouldBeAbleToSwitchToAFrameByItsIndex()
{
driver.Url = framesetPage;
-
- driver.FindElement(By.LinkText("top")).Click();
-
-
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(1000));
-
- Assert.AreEqual("XHTML Test Page", driver.Title);
- Assert.AreEqual("XHTML Test Page",
driver.FindElement(By.XPath("/html/head/title")).Text);
+ driver.SwitchTo().Frame(1);
+
+ Assert.AreEqual("2",
driver.FindElement(By.Id("pageNumber")).Text);
}
[Test]
- public void
ShouldNotAutomaticallySwitchFocusToAnIFrameWhenAPageContainingThemIsLoaded()
+ public void ShouldBeAbleToSwitchToAnIframeByItsIndex()
{
driver.Url = iframePage;
-
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));
- driver.FindElement(By.Id("iframe_page_heading"));
+ driver.SwitchTo().Frame(0);
+
+ Assert.AreEqual("name",
driver.FindElement(By.Name("id-name1")).Value);
}
[Test]
- public void
ShouldAllowAUserToSwitchFromAnIframeBackToTheMainContentOfThePage()
- {
- driver.Url = iframePage;
- driver.SwitchTo().Frame(0);
-
- driver.SwitchTo().DefaultContent();
- driver.FindElement(By.Id("iframe_page_heading"));
+ public void ShouldBeAbleToSwitchToAFrameByItsName()
+ {
+ driver.Url = framesetPage;
+ driver.SwitchTo().Frame("fourth");
+ Assert.AreEqual("child1",
driver.FindElement(By.TagName("frame")).GetAttribute("name"));
+
}
[Test]
- [IgnoreBrowser(Browser.Chrome, "Can't execute script in iframe,
track crbug 20773")]
- public void
ShouldAllowTheUserToSwitchToAnIFrameAndRemainFocusedOnIt()
+ public void ShouldBeAbleToSwitchToAnIframeByItsName()
{
driver.Url = iframePage;
- driver.SwitchTo().Frame(0);
-
- driver.FindElement(By.Id("submitButton")).Click();
-
-
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));
-
- String hello = driver.FindElement(By.Id("greeting")).Text;
- Assert.AreEqual(hello, "Success!");
+ driver.SwitchTo().Frame("iframe1-name");
+ Assert.AreEqual("name",
driver.FindElement(By.Name("id-name1")).Value);
+
}
[Test]
- public void ShouldBeAbleToClickInAFrame()
+ public void ShouldBeAbleToSwitchToAFrameByItsID()
{
driver.Url = framesetPage;
- driver.SwitchTo().Frame("third");
-
- driver.FindElement(By.Id("submitButton")).Click();
-
-
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));
-
- String hello = driver.FindElement(By.Id("greeting")).Text;
- Assert.AreEqual(hello, "Success!");
- driver.SwitchTo().DefaultContent();
+ driver.SwitchTo().Frame("fifth");
+ Assert.AreEqual("Open new window",
driver.FindElement(By.Name("windowOne")).Text);
+
}
[Test]
- [IgnoreBrowser(Browser.Chrome)]
- [IgnoreBrowser(Browser.HtmlUnit)]
- public void ShouldBeAbleToClickInASubFrame()
+ public void ShouldBeAbleToSwitchToAnIframeByItsID()
+ {
+ driver.Url = iframePage;
+ driver.SwitchTo().Frame("iframe1");
+ Assert.AreEqual("name",
driver.FindElement(By.Name("id-name1")).Value);
+ }
+
+ [Test]
+ public void
ShouldBeAbleToSwitchToAFrameUsingAPreviouslyLocatedWebElement()
{
driver.Url = framesetPage;
- driver.SwitchTo().Frame("sixth.iframe1");
-
- // This should replaxe frame "iframe1" inside frame "sixth" ...
- driver.FindElement(By.Id("submitButton")).Click();
-
-
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));
- // driver should still be focused on frame "iframe1" inside
frame "sixth" ...
- String hello = driver.FindElement(By.Id("greeting")).Text;
- Assert.AreEqual(hello, "Success!");
-
- // Make sure it was really frame "iframe1" inside
frame "sixth" which was replaced ...
-
driver.SwitchTo().DefaultContent().SwitchTo().Frame("sixth.iframe1");
- hello = driver.FindElement(By.Id("greeting")).Text;
- Assert.AreEqual(hello, "Success!");
+ IWebElement frame = driver.FindElement(By.TagName("frame"));
+ driver.SwitchTo().Frame(frame);
+ Assert.AreEqual("1",
driver.FindElement(By.Id("pageNumber")).Text);
+ }
+
+ // @Ignore(value = SELENESE, reason
= "switchTo().frame(WebElement) not supported with Selenium")
+ [Test]
+ public void
ShouldBeAbleToSwitchToAnIFrameUsingAPreviouslyLocatedWebElement()
+ {
+ driver.Url = iframePage;
+ IWebElement frame = driver.FindElement(By.TagName("iframe"));
+ driver.SwitchTo().Frame(frame);
+ Assert.AreEqual("name",
driver.FindElement(By.Name("id-name1")).Value);
+
}
[Test]
- public void ShouldBeAbleToSelectAFrameByName()
+ [ExpectedException(typeof(NoSuchFrameException))]
+ public void ShouldEnsureElementIsAFrameBeforeSwitching()
{
driver.Url = framesetPage;
+ IWebElement frame = driver.FindElement(By.TagName("frameset"));
+ driver.SwitchTo().Frame(frame);
+ }
+
+ [Test]
+ public void
FrameSearchesShouldBeRelativeToTheCurrentlySelectedFrame()
+ {
+ driver.Url = framesetPage;
driver.SwitchTo().Frame("second");
-
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "2");
-
+ Assert.AreEqual("2",
driver.FindElement(By.Id("pageNumber")).Text);
+
+ try
+ {
+ driver.SwitchTo().Frame("third");
+ Assert.Fail();
+ }
+ catch (NoSuchFrameException)
+ {
+ // Do nothing
+ }
+
+ driver.SwitchTo().DefaultContent();
driver.SwitchTo().Frame("third");
- driver.FindElement(By.Id("changeme")).Select();
-
+
+ try
+ {
+ driver.SwitchTo().Frame("second");
+ Assert.Fail();
+ }
+ catch (NoSuchFrameException)
+ {
+ // Do nothing
+ }
+
+ driver.SwitchTo().DefaultContent();
driver.SwitchTo().Frame("second");
-
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "2");
+ Assert.AreEqual("2",
driver.FindElement(By.Id("pageNumber")).Text);
}
[Test]
- public void ShouldSelectChildFramesByUsingADotSeparatedString()
+ public void ShouldSelectChildFramesByChainedCalls()
{
driver.Url = framesetPage;
-
- driver.SwitchTo().Frame("fourth.child2");
-
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "11");
+ driver.SwitchTo().Frame("fourth").SwitchTo().Frame("child2");
+ Assert.AreEqual("11",
driver.FindElement(By.Id("pageNumber")).Text);
}
[Test]
[IgnoreBrowser(Browser.IE)]
- [IgnoreBrowser(Browser.Firefox)]
- [IgnoreBrowser(Browser.Chrome)]
- public void ShouldSelectChildFramesByChainedCalls()
+ [ExpectedException(typeof(NoSuchFrameException))]
+ public void
ShouldThrowFrameNotFoundExceptionLookingUpSubFramesWithSuperFrameNames()
{
driver.Url = framesetPage;
-
- driver.SwitchTo().Frame("fourth").SwitchTo().Frame("child2");
- Assert.AreEqual("11",
driver.FindElement(By.Id("pageNumber")).Text);
+ driver.SwitchTo().Frame("fourth");
+ driver.SwitchTo().Frame("second");
+
}
[Test]
- public void ShouldSwitchToChildFramesTreatingNumbersAsIndex()
- {
- driver.Url = framesetPage;
-
- driver.SwitchTo().Frame("fourth.1");
-
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "11");
+ [ExpectedException(typeof(NoSuchFrameException))]
+ public void ShouldThrowAnExceptionWhenAFrameCannotBeFound()
+ {
+ driver.Url = xhtmlTestPage;
+ driver.SwitchTo().Frame("Nothing here");
+ }
+
+ [Test]
+ [ExpectedException(typeof(NoSuchFrameException))]
+ public void ShouldThrowAnExceptionWhenAFrameCannotBeFoundByIndex()
+ {
+ driver.Url = xhtmlTestPage;
+ driver.SwitchTo().Frame(27);
}
+ //
----------------------------------------------------------------------------------------------
+ //
+ // General frame handling behavior tests
+ //
+ //
----------------------------------------------------------------------------------------------
[Test]
- [IgnoreBrowser(Browser.Firefox, "Frame parsing issue with both
parent and child as indexes")]
- public void
ShouldSwitchToChildFramesTreatingParentAndChildNumbersAsIndex()
+ public void
ShouldContinueToReferToTheSameFrameOnceItHasBeenSelected()
{
driver.Url = framesetPage;
- driver.SwitchTo().Frame("3.1");
-
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "11");
+ driver.SwitchTo().Frame(2);
+ IWebElement checkbox =
driver.FindElement(By.XPath("//input[@name='checky']"));
+ checkbox.Toggle();
+ checkbox.Submit();
+
+ Assert.AreEqual("Success!",
driver.FindElement(By.XPath("//p")).Text);
}
[Test]
- [IgnoreBrowser(Browser.Chrome)]
- [ExpectedException(typeof(NoSuchFrameException))]
- public void
ShouldThrowFrameNotFoundExceptionLookingUpSubFramesWithSuperFrameNames()
+ public void
ShouldFocusOnTheReplacementWhenAFrameFollowsALinkToA_TopTargettedPage()
{
driver.Url = framesetPage;
- driver.SwitchTo().Frame("fourth.second");
-
+
+ driver.SwitchTo().Frame(0);
+ driver.FindElement(By.LinkText("top")).Click();
+
+ // TODO(simon): Avoid going too fast when native events are
there.
+ System.Threading.Thread.Sleep(1000);
+ Assert.AreEqual("XHTML Test Page", driver.Title);
+ Assert.AreEqual("XHTML Test Page",
driver.FindElement(By.XPath("/html/head/title")).Text);
}
[Test]
- [NeedsFreshDriver(AfterTest = true)]
- public void
ClosingTheFinalBrowserWindowShouldNotCauseAnExceptionToBeThrown()
- {
- driver.Url = simpleTestPage;
- driver.Close();
- }
+ public void
ShouldAllowAUserToSwitchFromAnIframeBackToTheMainContentOfThePage()
+ {
+ driver.Url = iframePage;
+ driver.SwitchTo().Frame(0);
+
+ driver.SwitchTo().DefaultContent();
+ driver.FindElement(By.Id("iframe_page_heading"));
+ }
+
[Test]
- public void ShouldBeAbleToFlipToAFrameIdentifiedByItsId()
- {
- driver.Url = framesetPage;
-
- driver.SwitchTo().Frame("fifth");
- driver.FindElement(By.Id("username"));
+ [IgnoreBrowser(Browser.Chrome, "Can't execute script in iframe,
track crbug 20773")]
+ public void
ShouldAllowTheUserToSwitchToAnIFrameAndRemainFocusedOnIt()
+ {
+ driver.Url = iframePage;
+ driver.SwitchTo().Frame(0);
+
+ driver.FindElement(By.Id("submitButton")).Click();
+
+ string hello = GetTextOfGreetingElement();
+ Assert.AreEqual(hello, "Success!");
}
[Test]
- [ExpectedException(typeof(NoSuchFrameException))]
- public void ShouldThrowAnExceptionWhenAFrameCannotBeFound()
- {
- driver.Url = xhtmlTestPage;
- driver.SwitchTo().Frame("Nothing here");
+ public void ShouldBeAbleToClickInAFrame()
+ {
+ driver.Url = framesetPage;
+ driver.SwitchTo().Frame("third");
+
+ // This should replace frame "third" ...
+ driver.FindElement(By.Id("submitButton")).Click();
+
+ // driver should still be focused on frame "third" ...
+ Assert.AreEqual("Success!", GetTextOfGreetingElement());
+
+ // Make sure it was really frame "third" which was replaced ...
+ driver.SwitchTo().DefaultContent().SwitchTo().Frame("third");
+ Assert.AreEqual("Success!", GetTextOfGreetingElement());
}
[Test]
- [ExpectedException(typeof(NoSuchFrameException))]
- public void ShouldThrowAnExceptionWhenAFrameCannotBeFoundByIndex()
- {
- driver.Url = xhtmlTestPage;
- driver.SwitchTo().Frame(27);
+ [IgnoreBrowser(Browser.Chrome)]
+ [IgnoreBrowser(Browser.HtmlUnit)]
+ public void ShouldBeAbleToClickInASubFrame()
+ {
+ driver.Url = framesetPage;
+ driver.SwitchTo().Frame("sixth").SwitchTo().Frame("iframe1");
+
+ // This should replaxe frame "iframe1" inside frame "sixth" ...
+ driver.FindElement(By.Id("submitButton")).Click();
+
+
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(500));
+ // driver should still be focused on frame "iframe1" inside
frame "sixth" ...
+ Assert.AreEqual("Success!", GetTextOfGreetingElement());
+
+ // Make sure it was really frame "iframe1" inside
frame "sixth" which was replaced ...
+
driver.SwitchTo().DefaultContent().SwitchTo().Frame("sixth").SwitchTo().Frame("iframe1");
+ Assert.AreEqual("Success!",
driver.FindElement(By.Id("greeting")).Text);
}
[Test]
- [IgnoreBrowser(Browser.IE, "As yet unimplemented")]
- public void
ShouldBeAbleToSwitchToTopLevelFrameWithDotInNameAssumingNoParentAndChildFrameExistWithTheSameName()
- {
- driver.Url = framesetPage;
- driver.SwitchTo().Frame("seventh.withadot");
- Assert.AreEqual("3",
driver.FindElement(By.Id("pageNumber")).Text);
+ [NeedsFreshDriver(AfterTest = true)]
+ public void
ClosingTheFinalBrowserWindowShouldNotCauseAnExceptionToBeThrown()
+ {
+ driver.Url = simpleTestPage;
+ driver.Close();
}
[Test]
- public void ShouldBeAbleToFindElementsInIframesByName()
- {
- driver.Url = iframePage;
-
- driver.SwitchTo().Frame("iframe1");
- IWebElement element = driver.FindElement(By.Name("id-name1"));
-
- Assert.IsNotNull(element);
+ public void ShouldBeAbleToFlipToAFrameIdentifiedByItsId()
+ {
+ driver.Url = framesetPage;
+
+ driver.SwitchTo().Frame("fifth");
+ driver.FindElement(By.Id("username"));
}
[Test]
@@ -243,24 +311,24 @@
Assert.IsNotNull(element);
}
+ //@Ignore(value = IE, reason = "IE8 on Win7 is not correctly
reporting the query string")
[Test]
public void GetCurrentUrl()
{
-
driver.Url = framesetPage;
driver.SwitchTo().Frame("second");
-
- String url =
EnvironmentManager.Instance.UrlBuilder.WhereIs("page/2");
- Assert.AreEqual(driver.Url, (url + "?title=Fish"));
+ string url =
EnvironmentManager.Instance.UrlBuilder.WhereIs("page/2");
+ Assert.AreEqual(url + "?title=Fish", driver.Url);
url =
EnvironmentManager.Instance.UrlBuilder.WhereIs("iframes.html");
driver.Url = iframePage;
- Assert.AreEqual(driver.Url, url);
+ Assert.AreEqual(url, driver.Url);
+
url =
EnvironmentManager.Instance.UrlBuilder.WhereIs("formPage.html");
driver.SwitchTo().Frame("iframe1");
- Assert.AreEqual(driver.Url, url);
+ Assert.AreEqual(url, driver.Url);
}
[Test]
@@ -271,7 +339,7 @@
driver.Url = deletingFrame;
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(1000));
driver.SwitchTo().Frame("iframe1");
-
+
IWebElement killIframe =
driver.FindElement(By.Id("killIframe"));
killIframe.Click();
@@ -307,13 +375,78 @@
}
}
+ //@Ignore(value = {IE, CHROME, SELENESE}, reason = "These drivers
still return frame title.")
[Test]
- public void ShouldReturnFrameTitleNotWindowTitle()
+ public void ShouldReturnWindowTitleInAFrameset()
{
driver.Url = framesetPage;
driver.SwitchTo().Frame("third");
- Assert.AreEqual("We Leave From Here", driver.Title);
+ Assert.AreEqual("Unique title", driver.Title);
}
+ // @JavascriptEnabled
+ [Test]
+ public void JavaScriptShouldExecuteInTheContextOfTheCurrentFrame()
+ {
+ IJavaScriptExecutor executor = driver as IJavaScriptExecutor;
+
+ driver.Url = framesetPage;
+ Assert.IsTrue((bool)executor.ExecuteScript("return window ===
window.top"));
+
+ driver.SwitchTo().Frame("third");
+ Assert.IsTrue((bool)executor.ExecuteScript("return window !==
window.top"));
+ }
+
+ //
----------------------------------------------------------------------------------------------
+ //
+ // Frame handling behavior tests not included in Java tests
+ //
+ //
----------------------------------------------------------------------------------------------
+
+ [Test]
+ public void ShouldBeAbleToSelectAFrameByName()
+ {
+ driver.Url = framesetPage;
+
+ driver.SwitchTo().Frame("second");
+
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "2");
+
+ driver.SwitchTo().DefaultContent().SwitchTo().Frame("third");
+ driver.FindElement(By.Id("changeme")).Select();
+
+ driver.SwitchTo().DefaultContent().SwitchTo().Frame("second");
+
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "2");
+ }
+
+ [Test]
+ public void ShouldBeAbleToFindElementsInIframesByName()
+ {
+ driver.Url = iframePage;
+
+ driver.SwitchTo().Frame("iframe1");
+ IWebElement element = driver.FindElement(By.Name("id-name1"));
+
+ Assert.IsNotNull(element);
+ }
+
+ private string GetTextOfGreetingElement()
+ {
+ string text = string.Empty;
+ DateTime end =
DateTime.Now.Add(TimeSpan.FromMilliseconds(3000));
+ while (DateTime.Now < end)
+ {
+ try
+ {
+ IWebElement element =
driver.FindElement(By.Id("greeting"));
+ text = element.Text;
+ break;
+ }
+ catch (NoSuchElementException)
+ {
+ }
+ }
+
+ return text;
+ }
}
}
=======================================
--- /trunk/common/test/csharp/webdriver-common-test/PageLoadingTest.cs Tue
Jul 20 06:36:12 2010
+++ /trunk/common/test/csharp/webdriver-common-test/PageLoadingTest.cs Thu
Dec 9 11:38:46 2010
@@ -74,7 +74,7 @@
IWebElement pageNumber =
driver.FindElement(By.XPath("//span[@id='pageNumber']"));
Assert.AreEqual(pageNumber.Text.Trim(), "1");
- driver.SwitchTo().Frame(1);
+ driver.SwitchTo().DefaultContent().SwitchTo().Frame(1);
pageNumber =
driver.FindElement(By.XPath("//span[@id='pageNumber']"));
Assert.AreEqual(pageNumber.Text.Trim(), "2");
}
=======================================
--- /trunk/common/test/csharp/webdriver-common-test/TargetLocatorTest.cs
Mon Jan 11 09:43:20 2010
+++ /trunk/common/test/csharp/webdriver-common-test/TargetLocatorTest.cs
Thu Dec 9 11:38:46 2010
@@ -29,8 +29,9 @@
[ExpectedException(typeof(ArgumentNullException))]
public void ShouldThrowExceptionAfterSwitchingToNullFrameName()
{
+ string frameName = null;
driver.Url = framesPage;
- driver.SwitchTo().Frame(null);
+ driver.SwitchTo().Frame(frameName);
}
[Test]
@@ -68,13 +69,29 @@
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "1");
driver.SwitchTo().DefaultContent();
-
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "1");
+ try
+ {
+ // DefaultContent should not have the element in it.
+
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "1");
+ Assert.Fail("Should not be able to get element in frame
from DefaultContent");
+ }
+ catch (NoSuchElementException)
+ {
+ }
driver.SwitchTo().Frame("second");
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "2");
driver.SwitchTo().DefaultContent();
-
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "1");
+ try
+ {
+ // DefaultContent should not have the element in it.
+
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "1");
+ Assert.Fail("Should not be able to get element in frame
from DefaultContent");
+ }
+ catch (NoSuchElementException)
+ {
+ }
}
[Test]
@@ -86,13 +103,29 @@
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "1");
driver.SwitchTo().DefaultContent();
-
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "1");
+ try
+ {
+ // DefaultContent should not have the element in it.
+
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "1");
+ Assert.Fail("Should not be able to get element in frame
from DefaultContent");
+ }
+ catch (NoSuchElementException)
+ {
+ }
driver.SwitchTo().Frame(1);
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "2");
driver.SwitchTo().DefaultContent();
-
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "1");
+ try
+ {
+ // DefaultContent should not have the element in it.
+
Assert.AreEqual(driver.FindElement(By.Id("pageNumber")).Text, "1");
+ Assert.Fail("Should not be able to get element in frame
from DefaultContent");
+ }
+ catch (NoSuchElementException)
+ {
+ }
}
}
=======================================
--- /trunk/jobbie/src/csharp/webdriver-ie/IE/InternetExplorerDriver.cs Wed
Nov 10 10:15:19 2010
+++ /trunk/jobbie/src/csharp/webdriver-ie/IE/InternetExplorerDriver.cs Thu
Dec 9 11:38:46 2010
@@ -1038,6 +1038,16 @@
////set to a valid frame... What's the best way of doing
this?
return driver;
}
+
+ /// <summary>
+ /// Move to a frame element.
+ /// </summary>
+ /// <param name="frameElement">a previously found FRAME or
IFRAME element.</param>
+ /// <returns>A WebDriver instance that is currently in
use.</returns>
+ public IWebDriver Frame(IWebElement frameElement)
+ {
+ throw new InvalidOperationException("Not yet implemented
for the IE driver");
+ }
/// <summary>
/// Change to the Window by passing in the name.
=======================================
---
/trunk/remote/client/src/csharp/webdriver-remote-client/RemoteWebDriver.cs
Sun Dec 5 04:15:48 2010
+++
/trunk/remote/client/src/csharp/webdriver-remote-client/RemoteWebDriver.cs
Thu Dec 9 11:38:46 2010
@@ -1303,6 +1303,33 @@
driver.Execute(DriverCommand.SwitchToFrame, parameters);
return driver;
}
+
+ /// <summary>
+ /// Move to a frame element.
+ /// </summary>
+ /// <param name="frameElement">a previously found FRAME or
IFRAME element.</param>
+ /// <returns>A WebDriver instance that is currently in
use.</returns>
+ public IWebDriver Frame(IWebElement frameElement)
+ {
+ if (frameElement == null)
+ {
+ throw new ArgumentNullException("frameElement", "Frame
element cannot be null");
+ }
+
+ RemoteWebElement convertedElement = frameElement as
RemoteWebElement;
+ if (convertedElement == null)
+ {
+ throw new ArgumentException("frameElement cannot be
converted to RemoteWebElement", "frameElement");
+ }
+
+ Dictionary<string, object> elementDictionary = new
Dictionary<string, object>();
+ elementDictionary.Add("ELEMENT",
convertedElement.InternalElementId);
+
+ Dictionary<string, object> parameters = new
Dictionary<string, object>();
+ parameters.Add("id", elementDictionary);
+ driver.Execute(DriverCommand.SwitchToFrame, parameters);
+ return driver;
+ }
/// <summary>
/// Change to the Window by passing in the name