Skip to content

Commit 9535fdf

Browse files
committed
Making .NET screenshot test resize window to remove scrollbar before screenshot
1 parent f74b4dc commit 9535fdf

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

dotnet/test/common/TakesScreenshotTest.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ public void ShouldCaptureScreenshotAtFramePage()
301301
}
302302

303303
[Test]
304-
[IgnoreBrowser(Browser.IE, "Color comparisons fail on IE")]
305304
public void ShouldCaptureScreenshotAtIFramePage()
306305
{
307306
ITakesScreenshot screenshotCapableDriver = driver as ITakesScreenshot;
@@ -312,7 +311,12 @@ public void ShouldCaptureScreenshotAtIFramePage()
312311

313312
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("screen/screen_iframes.html");
314313

314+
// Resize the window to avoid scrollbars in screenshot
315+
Size originalSize = driver.Manage().Window.Size;
316+
driver.Manage().Window.Size = new Size(1040, 700);
317+
315318
Screenshot screenshot = screenshotCapableDriver.GetScreenshot();
319+
driver.Manage().Window.Size = originalSize;
316320

317321
HashSet<string> actualColors = ScanActualColors(screenshot,
318322
/* stepX in pixels */ 5,
@@ -366,7 +370,6 @@ public void ShouldCaptureScreenshotAtFramePageAfterSwitching()
366370
}
367371

368372
[Test]
369-
[IgnoreBrowser(Browser.IE, "Color comparisons fail on IE")]
370373
[IgnoreBrowser(Browser.Firefox, "Color comparisons fail on Firefox")]
371374
public void ShouldCaptureScreenshotAtIFramePageAfterSwitching()
372375
{
@@ -378,9 +381,14 @@ public void ShouldCaptureScreenshotAtIFramePageAfterSwitching()
378381

379382
driver.Url = EnvironmentManager.Instance.UrlBuilder.WhereIs("screen/screen_iframes.html");
380383

384+
// Resize the window to avoid scrollbars in screenshot
385+
Size originalSize = driver.Manage().Window.Size;
386+
driver.Manage().Window.Size = new Size(1040, 700);
387+
381388
driver.SwitchTo().Frame(driver.FindElement(By.Id("iframe2")));
382389

383390
Screenshot screenshot = screenshotCapableDriver.GetScreenshot();
391+
driver.Manage().Window.Size = originalSize;
384392

385393
HashSet<string> actualColors = ScanActualColors(screenshot,
386394
/* stepX in pixels */ 5,

0 commit comments

Comments
 (0)