diff --git a/dotnet/test/common/WindowTest.cs b/dotnet/test/common/WindowTest.cs index 3836c397f2a5c..aaa3eaa9f5ad6 100644 --- a/dotnet/test/common/WindowTest.cs +++ b/dotnet/test/common/WindowTest.cs @@ -79,7 +79,7 @@ public void ShouldBeAbleToSetThePositionOfTheCurrentWindow() { IWindow window = driver.Manage().Window; Point position = window.Position; - + Point targetPosition = new Point(position.X + 10, position.Y + 10); window.Position = targetPosition; @@ -98,21 +98,78 @@ public void ShouldBeAbleToSetThePositionOfTheCurrentWindow() [IgnoreBrowser(Browser.PhantomJS, "As a headless browser, there is no position of the window.")] public void ShouldBeAbleToMaximizeTheCurrentWindow() { - Size targetSize = new Size(275, 275); - IWindow window = driver.Manage().Window; - - window.Size = targetSize; - WaitFor(WindowHeightToBeEqualTo(targetSize.Height)); - WaitFor(WindowWidthToBeEqualTo(targetSize.Height)); + Size targetSize = new Size(450, 275); - window.Maximize(); - WaitFor(WindowHeightToBeGreaterThan(targetSize.Height)); - WaitFor(WindowWidthToBeGreaterThan(targetSize.Width)); + ChangeSizeTo(targetSize); + Maximize(); + + IWindow window = driver.Manage().Window; Assert.Greater(window.Size.Height, targetSize.Height); Assert.Greater(window.Size.Width, targetSize.Width); } + [Test] + [IgnoreBrowser(Browser.HtmlUnit, "Not implemented in driver")] + [IgnoreBrowser(Browser.Opera, "Not implemented in driver")] + [IgnoreBrowser(Browser.Android, "Not implemented in driver")] + [IgnoreBrowser(Browser.IPhone, "Not implemented in driver")] + [IgnoreBrowser(Browser.PhantomJS, "As a headless browser, there is no position of the window.")] + public void ShouldBeAbleToMaximizeTheWindowFromFrame() + { + driver.Url = framesetPage; + ChangeSizeTo(new Size(450, 275)); + + driver.SwitchTo().Frame("fourth"); + try + { + Maximize(); + } + finally + { + driver.SwitchTo().DefaultContent(); + } + } + + [Test] + [IgnoreBrowser(Browser.HtmlUnit, "Not implemented in driver")] + [IgnoreBrowser(Browser.Opera, "Not implemented in driver")] + [IgnoreBrowser(Browser.Android, "Not implemented in driver")] + [IgnoreBrowser(Browser.IPhone, "Not implemented in driver")] + [IgnoreBrowser(Browser.PhantomJS, "As a headless browser, there is no position of the window.")] + public void ShouldBeAbleToMaximizeTheWindowFromIframe() + { + driver.Url = iframePage; + ChangeSizeTo(new Size(450, 275)); + + driver.SwitchTo().Frame("iframe1-name"); + try + { + Maximize(); + } + finally + { + driver.SwitchTo().DefaultContent(); + } + } + + private void Maximize() + { + IWindow window = driver.Manage().Window; + Size currentSize = window.Size; + window.Maximize(); + WaitFor(WindowHeightToBeGreaterThan(currentSize.Height)); + WaitFor(WindowWidthToBeGreaterThan(currentSize.Width)); + } + + private void ChangeSizeTo(Size targetSize) + { + IWindow window = driver.Manage().Window; + window.Size = targetSize; + WaitFor(WindowHeightToBeEqualTo(targetSize.Height)); + WaitFor(WindowWidthToBeEqualTo(targetSize.Width)); + } + private Func WindowHeightToBeEqualTo(int height) { return () => { return driver.Manage().Window.Size.Height == height; }; diff --git a/java/client/test/org/openqa/selenium/WindowTest.java b/java/client/test/org/openqa/selenium/WindowTest.java index e1c207e5743ca..3aec7e9964f86 100644 --- a/java/client/test/org/openqa/selenium/WindowTest.java +++ b/java/client/test/org/openqa/selenium/WindowTest.java @@ -121,7 +121,7 @@ public void testSetsThePositionOfTheCurrentWindow() throws InterruptedException public void testCanMaximizeTheWindow() throws InterruptedException { assumeThereIsAWindowManager(); - changeSizeTo(new Dimension(275, 275)); + changeSizeTo(new Dimension(450, 275)); maximize(); } @@ -131,7 +131,7 @@ public void testCanMaximizeTheWindowFromFrame() throws InterruptedException { assumeThereIsAWindowManager(); driver.get(pages.framesetPage); - changeSizeTo(new Dimension(275, 275)); + changeSizeTo(new Dimension(450, 275)); driver.switchTo().frame("fourth"); try { @@ -147,7 +147,7 @@ public void testCanMaximizeTheWindowFromIframe() throws InterruptedException { assumeThereIsAWindowManager(); driver.get(pages.iframePage); - changeSizeTo(new Dimension(275, 275)); + changeSizeTo(new Dimension(450, 275)); driver.switchTo().frame("iframe1-name"); try {