Skip to content

Commit 006bc53

Browse files
shbenzerharsha509
andauthored
Added Cs Print Options Examples (#1993)[deploy site]
* Fixed Incorrect Example Lines in PrintOptions Page * Added C# PrintOptions Examples --------- Co-authored-by: Sri Harsha <12621691+harsha509@users.noreply.github.com>
1 parent 6c03eee commit 006bc53

File tree

5 files changed

+109
-56
lines changed

5 files changed

+109
-56
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
}

website_and_docs/content/documentation/webdriver/interactions/print_page.en.md

+7-14
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the
1919
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L12-L18" >}}
2020
{{< /tab >}}
2121
{{< tab header="CSharp" >}}
22-
{{< badge-code >}}
22+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L12-L19" >}}
2323
{{< /tab >}}
2424
{{< tab header="Ruby" >}}
2525
{{< badge-code >}}
26-
{{< badge-code >}}
2726
{{< /tab >}}
2827
{{< tab header="Python" >}}
2928
{{< badge-code >}}
@@ -44,11 +43,10 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r
4443
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L21-L27" >}}
4544
{{< /tab >}}
4645
{{< tab header="CSharp" >}}
47-
{{< badge-code >}}
46+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L22-L29" >}}
4847
{{< /tab >}}
4948
{{< tab header="Ruby" >}}
5049
{{< badge-code >}}
51-
{{< badge-code >}}
5250
{{< /tab >}}
5351
{{< tab header="Python" >}}
5452
{{< badge-code >}}
@@ -69,11 +67,10 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap
6967
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L30-L36" >}}
7068
{{< /tab >}}
7169
{{< tab header="CSharp" >}}
72-
{{< badge-code >}}
70+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L32-L38" >}}
7371
{{< /tab >}}
7472
{{< tab header="Ruby" >}}
7573
{{< badge-code >}}
76-
{{< badge-code >}}
7774
{{< /tab >}}
7875
{{< tab header="Python" >}}
7976
{{< badge-code >}}
@@ -94,11 +91,10 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi
9491
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L40-L49" >}}
9592
{{< /tab >}}
9693
{{< tab header="CSharp" >}}
97-
{{< badge-code >}}
94+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L51-L57" >}}
9895
{{< /tab >}}
9996
{{< tab header="Ruby" >}}
10097
{{< badge-code >}}
101-
{{< badge-code >}}
10298
{{< /tab >}}
10399
{{< tab header="Python" >}}
104100
{{< badge-code >}}
@@ -119,11 +115,10 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa
119115
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L52-L58" >}}
120116
{{< /tab >}}
121117
{{< tab header="CSharp" >}}
122-
{{< badge-code >}}
118+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L61-L68" >}}
123119
{{< /tab >}}
124120
{{< tab header="Ruby" >}}
125121
{{< badge-code >}}
126-
{{< badge-code >}}
127122
{{< /tab >}}
128123
{{< tab header="Python" >}}
129124
{{< badge-code >}}
@@ -144,11 +139,10 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b
144139
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L61-L67" >}}
145140
{{< /tab >}}
146141
{{< tab header="CSharp" >}}
147-
{{< badge-code >}}
142+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L41-L48" >}}
148143
{{< /tab >}}
149144
{{< tab header="Ruby" >}}
150145
{{< badge-code >}}
151-
{{< badge-code >}}
152146
{{< /tab >}}
153147
{{< tab header="Python" >}}
154148
{{< badge-code >}}
@@ -169,11 +163,10 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether t
169163
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L70-L76" >}}
170164
{{< /tab >}}
171165
{{< tab header="CSharp" >}}
172-
{{< badge-code >}}
166+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L71-L78" >}}
173167
{{< /tab >}}
174168
{{< tab header="Ruby" >}}
175169
{{< badge-code >}}
176-
{{< badge-code >}}
177170
{{< /tab >}}
178171
{{< tab header="Python" >}}
179172
{{< badge-code >}}

website_and_docs/content/documentation/webdriver/interactions/print_page.ja.md

+7-14
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the
1919
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L12-L18" >}}
2020
{{< /tab >}}
2121
{{< tab header="CSharp" >}}
22-
{{< badge-code >}}
22+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L12-L19" >}}
2323
{{< /tab >}}
2424
{{< tab header="Ruby" >}}
2525
{{< badge-code >}}
26-
{{< badge-code >}}
2726
{{< /tab >}}
2827
{{< tab header="Python" >}}
2928
{{< badge-code >}}
@@ -44,11 +43,10 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r
4443
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L21-L27" >}}
4544
{{< /tab >}}
4645
{{< tab header="CSharp" >}}
47-
{{< badge-code >}}
46+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L22-L29" >}}
4847
{{< /tab >}}
4948
{{< tab header="Ruby" >}}
5049
{{< badge-code >}}
51-
{{< badge-code >}}
5250
{{< /tab >}}
5351
{{< tab header="Python" >}}
5452
{{< badge-code >}}
@@ -69,11 +67,10 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap
6967
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L30-L36" >}}
7068
{{< /tab >}}
7169
{{< tab header="CSharp" >}}
72-
{{< badge-code >}}
70+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L32-L38" >}}
7371
{{< /tab >}}
7472
{{< tab header="Ruby" >}}
7573
{{< badge-code >}}
76-
{{< badge-code >}}
7774
{{< /tab >}}
7875
{{< tab header="Python" >}}
7976
{{< badge-code >}}
@@ -94,11 +91,10 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi
9491
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L40-L49" >}}
9592
{{< /tab >}}
9693
{{< tab header="CSharp" >}}
97-
{{< badge-code >}}
94+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L51-L57" >}}
9895
{{< /tab >}}
9996
{{< tab header="Ruby" >}}
10097
{{< badge-code >}}
101-
{{< badge-code >}}
10298
{{< /tab >}}
10399
{{< tab header="Python" >}}
104100
{{< badge-code >}}
@@ -119,11 +115,10 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa
119115
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L52-L58" >}}
120116
{{< /tab >}}
121117
{{< tab header="CSharp" >}}
122-
{{< badge-code >}}
118+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L61-L68" >}}
123119
{{< /tab >}}
124120
{{< tab header="Ruby" >}}
125121
{{< badge-code >}}
126-
{{< badge-code >}}
127122
{{< /tab >}}
128123
{{< tab header="Python" >}}
129124
{{< badge-code >}}
@@ -144,11 +139,10 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b
144139
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L61-L67" >}}
145140
{{< /tab >}}
146141
{{< tab header="CSharp" >}}
147-
{{< badge-code >}}
142+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L41-L48" >}}
148143
{{< /tab >}}
149144
{{< tab header="Ruby" >}}
150145
{{< badge-code >}}
151-
{{< badge-code >}}
152146
{{< /tab >}}
153147
{{< tab header="Python" >}}
154148
{{< badge-code >}}
@@ -169,11 +163,10 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether t
169163
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L70-L76" >}}
170164
{{< /tab >}}
171165
{{< tab header="CSharp" >}}
172-
{{< badge-code >}}
166+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L71-L78" >}}
173167
{{< /tab >}}
174168
{{< tab header="Ruby" >}}
175169
{{< badge-code >}}
176-
{{< badge-code >}}
177170
{{< /tab >}}
178171
{{< tab header="Python" >}}
179172
{{< badge-code >}}

website_and_docs/content/documentation/webdriver/interactions/print_page.pt-br.md

+7-14
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the
1919
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L12-L18" >}}
2020
{{< /tab >}}
2121
{{< tab header="CSharp" >}}
22-
{{< badge-code >}}
22+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L12-L19" >}}
2323
{{< /tab >}}
2424
{{< tab header="Ruby" >}}
2525
{{< badge-code >}}
26-
{{< badge-code >}}
2726
{{< /tab >}}
2827
{{< tab header="Python" >}}
2928
{{< badge-code >}}
@@ -44,11 +43,10 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r
4443
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L21-L27" >}}
4544
{{< /tab >}}
4645
{{< tab header="CSharp" >}}
47-
{{< badge-code >}}
46+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L22-L29" >}}
4847
{{< /tab >}}
4948
{{< tab header="Ruby" >}}
5049
{{< badge-code >}}
51-
{{< badge-code >}}
5250
{{< /tab >}}
5351
{{< tab header="Python" >}}
5452
{{< badge-code >}}
@@ -69,11 +67,10 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap
6967
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L30-L36" >}}
7068
{{< /tab >}}
7169
{{< tab header="CSharp" >}}
72-
{{< badge-code >}}
70+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L32-L38" >}}
7371
{{< /tab >}}
7472
{{< tab header="Ruby" >}}
7573
{{< badge-code >}}
76-
{{< badge-code >}}
7774
{{< /tab >}}
7875
{{< tab header="Python" >}}
7976
{{< badge-code >}}
@@ -94,11 +91,10 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi
9491
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L40-L49" >}}
9592
{{< /tab >}}
9693
{{< tab header="CSharp" >}}
97-
{{< badge-code >}}
94+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L51-L57" >}}
9895
{{< /tab >}}
9996
{{< tab header="Ruby" >}}
10097
{{< badge-code >}}
101-
{{< badge-code >}}
10298
{{< /tab >}}
10399
{{< tab header="Python" >}}
104100
{{< badge-code >}}
@@ -119,11 +115,10 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa
119115
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L52-L58" >}}
120116
{{< /tab >}}
121117
{{< tab header="CSharp" >}}
122-
{{< badge-code >}}
118+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L61-L68" >}}
123119
{{< /tab >}}
124120
{{< tab header="Ruby" >}}
125121
{{< badge-code >}}
126-
{{< badge-code >}}
127122
{{< /tab >}}
128123
{{< tab header="Python" >}}
129124
{{< badge-code >}}
@@ -144,11 +139,10 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b
144139
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L61-L67" >}}
145140
{{< /tab >}}
146141
{{< tab header="CSharp" >}}
147-
{{< badge-code >}}
142+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L41-L48" >}}
148143
{{< /tab >}}
149144
{{< tab header="Ruby" >}}
150145
{{< badge-code >}}
151-
{{< badge-code >}}
152146
{{< /tab >}}
153147
{{< tab header="Python" >}}
154148
{{< badge-code >}}
@@ -169,11 +163,10 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether t
169163
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/PrintOptionsTest.java#L70-L76" >}}
170164
{{< /tab >}}
171165
{{< tab header="CSharp" >}}
172-
{{< badge-code >}}
166+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L71-L78" >}}
173167
{{< /tab >}}
174168
{{< tab header="Ruby" >}}
175169
{{< badge-code >}}
176-
{{< badge-code >}}
177170
{{< /tab >}}
178171
{{< tab header="Python" >}}
179172
{{< badge-code >}}

0 commit comments

Comments
 (0)