Skip to content

Commit 0e75a52

Browse files
committed
Rework one test
1 parent 9999f72 commit 0e75a52

File tree

3 files changed

+65
-66
lines changed

3 files changed

+65
-66
lines changed

dotnet/test/common/DriverTestFixture.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public abstract class DriverTestFixture
8888
public string scrollFrameOutOfViewport = EnvironmentManager.Instance.UrlBuilder.WhereIs("scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html");
8989
public string scrollFrameInViewport = EnvironmentManager.Instance.UrlBuilder.WhereIs("scrolling_tests/frame_with_nested_scrolling_frame.html");
9090

91+
public string printPage = EnvironmentManager.Instance.UrlBuilder.WhereIs("printPage.html");
92+
9193
protected IWebDriver driver;
9294

9395
public IWebDriver DriverInstance

dotnet/test/common/PrintOptionsTest.cs

Lines changed: 0 additions & 66 deletions
This file was deleted.

dotnet/test/common/PrintTest.cs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using NUnit.Framework;
2+
3+
namespace OpenQA.Selenium
4+
{
5+
[TestFixture]
6+
public class PrintTest : DriverTestFixture
7+
{
8+
private const string MagicString = "JVBER";
9+
private ISupportsPrint printer;
10+
11+
[SetUp]
12+
public void LocalSetUp()
13+
{
14+
Assert.That(driver, Is.InstanceOf<ISupportsPrint>(), $"Driver does not support {nameof(ISupportsPrint)}.");
15+
16+
printer = driver as ISupportsPrint;
17+
18+
driver.Navigate().GoToUrl(this.printPage);
19+
}
20+
21+
[Test]
22+
public void CanPrintPage()
23+
{
24+
var pdf = printer.Print(new PrintOptions());
25+
26+
Assert.That(pdf.AsBase64EncodedString, Does.Contain(MagicString), "Printed PDF does not contain the expected magic string.");
27+
}
28+
29+
//[Test]
30+
//[Ignore("Skipped for Chrome because it needs to run headless, a workaround is needed.")]
31+
//public void CanPrintTwoPages()
32+
//{
33+
// PrintOptions printOptions = new PrintOptions
34+
// {
35+
// PageRanges = "1-2"
36+
// };
37+
38+
// var pdf = printer.Print(printOptions);
39+
// Assert.That(pdf.Content.Contains(MAGIC_STRING), Is.True, "Printed PDF does not contain the expected magic string.");
40+
//}
41+
42+
//[Test]
43+
//[Ignore("Skipped for Chrome because it needs to run headless, a workaround is needed.")]
44+
//public void CanPrintWithValidParams()
45+
//{
46+
// PrintOptions printOptions = new PrintOptions();
47+
48+
// //set all options
49+
// printOptions.PageRanges = "1";
50+
// printOptions.Orientation = PrintOrientation.Landscape;
51+
// printOptions.PageSize = new PageSize();
52+
// printOptions.Scale = 0.5;
53+
// printOptions.DisplayHeaderFooter = true;
54+
// printOptions.HeaderTemplate = "Header";
55+
// printOptions.FooterTemplate = "Footer";
56+
// printOptions.PrintBackground = true;
57+
// printOptions.shrinkToFit = true;
58+
59+
// var pdf = printer.Print(printOptions);
60+
// Assert.That(pdf.Content.Contains(MAGIC_STRING), Is.True, "Printed PDF does not contain the expected magic string.");
61+
//}
62+
}
63+
}

0 commit comments

Comments
 (0)