Skip to content

Commit

Permalink
Fixing Window sizing tests for Firefox 26 on Windows.
Browse files Browse the repository at this point in the history
Starting with Firefox 26, the minimum width of the window is ~405 pixels.
The tests attempted to set the window width to 275 pixels, which would not
succeed. We now use 450 pixels as the width to set to.
  • Loading branch information
jimevans committed Dec 13, 2013
1 parent 64c68bb commit 3c58c82
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 13 deletions.
77 changes: 67 additions & 10 deletions dotnet/test/common/WindowTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<bool> WindowHeightToBeEqualTo(int height)
{
return () => { return driver.Manage().Window.Size.Height == height; };
Expand Down
6 changes: 3 additions & 3 deletions java/client/test/org/openqa/selenium/WindowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 3c58c82

Please sign in to comment.