1+ using System ;
2+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
3+ using OpenQA . Selenium ;
4+ using OpenQA . Selenium . Chrome ;
5+
6+ namespace SeleniumDocumentation . SeleniumInteractions
7+ {
8+ [ TestClass ]
9+ public class PrintOptionsTest
10+ {
11+ [ TestMethod ]
12+ public void TestOrientation ( )
13+ {
14+ IWebDriver driver = new ChromeDriver ( ) ;
15+ driver . Navigate ( ) . GoToUrl ( "https://selenium.dev" ) ;
16+ PrintOptions printOptions = new PrintOptions ( ) ;
17+ printOptions . Orientation = PrintOrientation . Landscape ;
18+ PrintOrientation currentOrientation = printOptions . Orientation ;
19+ }
20+
21+ [ TestMethod ]
22+ public void TestRange ( )
23+ {
24+ IWebDriver driver = new ChromeDriver ( ) ;
25+ driver . Navigate ( ) . GoToUrl ( "https://selenium.dev" ) ;
26+ PrintOptions printOptions = new PrintOptions ( ) ;
27+ printOptions . AddPageRangeToPrint ( "1-3" ) ; // add range of pages
28+ printOptions . AddPageToPrint ( 5 ) ; // add individual page
29+ }
30+
31+ [ TestMethod ]
32+ public void TestSize ( )
33+ {
34+ IWebDriver driver = new ChromeDriver ( ) ;
35+ driver . Navigate ( ) . GoToUrl ( "https://www.selenium.dev/" ) ;
36+ PrintOptions printOptions = new PrintOptions ( ) ;
37+ PrintOptions . PageSize currentDimensions = printOptions . PageDimensions ;
38+ }
39+
40+ [ TestMethod ]
41+ public void TestBackgrounds ( )
42+ {
43+ IWebDriver driver = new ChromeDriver ( ) ;
44+ driver . Navigate ( ) . GoToUrl ( "https://www.selenium.dev/" ) ;
45+ PrintOptions printOptions = new PrintOptions ( ) ;
46+ printOptions . OutputBackgroundImages = true ;
47+ bool currentBackgrounds = printOptions . OutputBackgroundImages ;
48+ }
49+
50+ [ TestMethod ]
51+ public void TestMargins ( )
52+ {
53+ IWebDriver driver = new ChromeDriver ( ) ;
54+ driver . Navigate ( ) . GoToUrl ( "https://www.selenium.dev/" ) ;
55+ PrintOptions printOptions = new PrintOptions ( ) ;
56+ PrintOptions . Margins currentMargins = printOptions . PageMargins ;
57+ }
58+
59+
60+ [ TestMethod ]
61+ public void TestScale ( )
62+ {
63+ IWebDriver driver = new ChromeDriver ( ) ;
64+ driver . Navigate ( ) . GoToUrl ( "https://www.selenium.dev/" ) ;
65+ PrintOptions printOptions = new PrintOptions ( ) ;
66+ printOptions . ScaleFactor = 0.5 ;
67+ double currentScale = printOptions . ScaleFactor ;
68+ }
69+
70+ [ TestMethod ]
71+ public void TestShrinkToFit ( )
72+ {
73+ IWebDriver driver = new ChromeDriver ( ) ;
74+ driver . Navigate ( ) . GoToUrl ( "https://www.selenium.dev/" ) ;
75+ PrintOptions printOptions = new PrintOptions ( ) ;
76+ printOptions . ShrinkToFit = true ;
77+ bool currentShrinkToFit = printOptions . ShrinkToFit ;
78+ }
79+ }
80+
81+ }
0 commit comments