Skip to content

Commit 6703150

Browse files
shbenzerharsha509
andauthored
Added Python Examples for PrintOptions() (#2000)[deploy site]
* Added Python Examples for PrintOptions() * fixed assertion error * now the assertion error is fixed --------- Co-authored-by: Sri Harsha <[email protected]>
1 parent 7391ac0 commit 6703150

File tree

5 files changed

+170
-112
lines changed

5 files changed

+170
-112
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import pytest
2+
from selenium import webdriver
3+
from selenium.webdriver.common.print_page_options import PrintOptions
4+
5+
@pytest.fixture()
6+
def driver():
7+
driver = webdriver.Chrome()
8+
yield driver
9+
driver.quit()
10+
11+
def test_orientation(driver):
12+
driver.get("https://www.selenium.dev/")
13+
print_options = PrintOptions()
14+
print_options.orientation = "landscape" ## landscape or portrait
15+
assert print_options.orientation == "landscape"
16+
17+
def test_range(driver):
18+
driver.get("https://www.selenium.dev/")
19+
print_options = PrintOptions()
20+
print_options.page_ranges = ["1, 2, 3"] ## ["1", "2", "3"] or ["1-3"]
21+
assert print_options.page_ranges == ["1, 2, 3"]
22+
23+
def test_size(driver):
24+
driver.get("https://www.selenium.dev/")
25+
print_options = PrintOptions()
26+
print_options.scale = 0.5 ## 0.1 to 2.0``
27+
assert print_options.scale == 0.5
28+
29+
def test_margin(driver):
30+
driver.get("https://www.selenium.dev/")
31+
print_options = PrintOptions()
32+
print_options.margin_top = 10
33+
print_options.margin_bottom = 10
34+
print_options.margin_left = 10
35+
print_options.margin_right = 10
36+
assert print_options.margin_top == 10
37+
assert print_options.margin_bottom == 10
38+
assert print_options.margin_left == 10
39+
assert print_options.margin_right == 10
40+
41+
def test_scale(driver):
42+
driver.get("https://www.selenium.dev/")
43+
print_options = PrintOptions()
44+
print_options.scale = 0.5 ## 0.1 to 2.0
45+
current_scale = print_options.scale
46+
assert current_scale == 0.5
47+
48+
def test_background(driver):
49+
driver.get("https://www.selenium.dev/")
50+
print_options = PrintOptions()
51+
print_options.background = True ## True or False
52+
assert print_options.background is True
53+
54+
def test_shrink_to_fit(driver):
55+
driver.get("https://www.selenium.dev/")
56+
print_options = PrintOptions()
57+
print_options.shrink_to_fit = True ## True or False
58+
assert print_options.shrink_to_fit is True

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the
2222
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L12-L19" >}}
2323
{{< /tab >}}
2424
{{< tab header="Ruby" >}}
25-
{{< badge-code >}}
25+
{{< badge-implementation >}}
2626
{{< /tab >}}
2727
{{< tab header="Python" >}}
28-
{{< badge-code >}}
28+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L11-L15" >}}
2929
{{< /tab >}}
3030
{{< tab header="JavaScript" >}}
31-
{{< badge-code >}}
31+
{{< badge-implementation >}}
3232
{{< /tab >}}
3333
{{< tab header="Kotlin" >}}
34-
{{< badge-code >}}
34+
{{< badge-implementation >}}
3535
{{< /tab >}}
3636
{{< /tabpane >}}
3737

@@ -46,16 +46,16 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r
4646
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L22-L29" >}}
4747
{{< /tab >}}
4848
{{< tab header="Ruby" >}}
49-
{{< badge-code >}}
49+
{{< badge-implementation >}}
5050
{{< /tab >}}
5151
{{< tab header="Python" >}}
52-
{{< badge-code >}}
52+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L17-L21" >}}
5353
{{< /tab >}}
5454
{{< tab header="JavaScript" >}}
55-
{{< badge-code >}}
55+
{{< badge-implementation >}}
5656
{{< /tab >}}
5757
{{< tab header="Kotlin" >}}
58-
{{< badge-code >}}
58+
{{< badge-implementation >}}
5959
{{< /tab >}}
6060
{{< /tabpane >}}
6161

@@ -70,16 +70,16 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap
7070
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L32-L38" >}}
7171
{{< /tab >}}
7272
{{< tab header="Ruby" >}}
73-
{{< badge-code >}}
73+
{{< badge-implementation >}}
7474
{{< /tab >}}
7575
{{< tab header="Python" >}}
76-
{{< badge-code >}}
76+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L23-L27" >}}
7777
{{< /tab >}}
7878
{{< tab header="JavaScript" >}}
79-
{{< badge-code >}}
79+
{{< badge-implementation >}}
8080
{{< /tab >}}
8181
{{< tab header="Kotlin" >}}
82-
{{< badge-code >}}
82+
{{< badge-implementation >}}
8383
{{< /tab >}}
8484
{{< /tabpane >}}
8585

@@ -94,16 +94,16 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi
9494
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L51-L57" >}}
9595
{{< /tab >}}
9696
{{< tab header="Ruby" >}}
97-
{{< badge-code >}}
97+
{{< badge-implementation >}}
9898
{{< /tab >}}
9999
{{< tab header="Python" >}}
100-
{{< badge-code >}}
100+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L29-L39" >}}
101101
{{< /tab >}}
102102
{{< tab header="JavaScript" >}}
103-
{{< badge-code >}}
103+
{{< badge-implementation >}}
104104
{{< /tab >}}
105105
{{< tab header="Kotlin" >}}
106-
{{< badge-code >}}
106+
{{< badge-implementation >}}
107107
{{< /tab >}}
108108
{{< /tabpane >}}
109109

@@ -118,16 +118,16 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa
118118
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L61-L68" >}}
119119
{{< /tab >}}
120120
{{< tab header="Ruby" >}}
121-
{{< badge-code >}}
121+
{{< badge-implementation >}}
122122
{{< /tab >}}
123123
{{< tab header="Python" >}}
124-
{{< badge-code >}}
124+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L41-L46" >}}
125125
{{< /tab >}}
126126
{{< tab header="JavaScript" >}}
127-
{{< badge-code >}}
127+
{{< badge-implementation >}}
128128
{{< /tab >}}
129129
{{< tab header="Kotlin" >}}
130-
{{< badge-code >}}
130+
{{< badge-implementation >}}
131131
{{< /tab >}}
132132
{{< /tabpane >}}
133133

@@ -142,16 +142,16 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b
142142
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L41-L48" >}}
143143
{{< /tab >}}
144144
{{< tab header="Ruby" >}}
145-
{{< badge-code >}}
145+
{{< badge-implementation >}}
146146
{{< /tab >}}
147147
{{< tab header="Python" >}}
148-
{{< badge-code >}}
148+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L48-L52" >}}
149149
{{< /tab >}}
150150
{{< tab header="JavaScript" >}}
151-
{{< badge-code >}}
151+
{{< badge-implementation >}}
152152
{{< /tab >}}
153153
{{< tab header="Kotlin" >}}
154-
{{< badge-code >}}
154+
{{< badge-implementation >}}
155155
{{< /tab >}}
156156
{{< /tabpane >}}
157157

@@ -166,15 +166,15 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether t
166166
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L71-L78" >}}
167167
{{< /tab >}}
168168
{{< tab header="Ruby" >}}
169-
{{< badge-code >}}
169+
{{< badge-implementation >}}
170170
{{< /tab >}}
171171
{{< tab header="Python" >}}
172-
{{< badge-code >}}
172+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L54-L58" >}}
173173
{{< /tab >}}
174174
{{< tab header="JavaScript" >}}
175-
{{< badge-code >}}
175+
{{< badge-implementation >}}
176176
{{< /tab >}}
177177
{{< tab header="Kotlin" >}}
178-
{{< badge-code >}}
178+
{{< badge-implementation >}}
179179
{{< /tab >}}
180180
{{< /tabpane >}}

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

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the
2222
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L12-L19" >}}
2323
{{< /tab >}}
2424
{{< tab header="Ruby" >}}
25-
{{< badge-code >}}
25+
{{< badge-implementation >}}
2626
{{< /tab >}}
2727
{{< tab header="Python" >}}
28-
{{< badge-code >}}
28+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L11-L15" >}}
2929
{{< /tab >}}
3030
{{< tab header="JavaScript" >}}
31-
{{< badge-code >}}
31+
{{< badge-implementation >}}
3232
{{< /tab >}}
3333
{{< tab header="Kotlin" >}}
34-
{{< badge-code >}}
34+
{{< badge-implementation >}}
3535
{{< /tab >}}
3636
{{< /tabpane >}}
3737

@@ -46,16 +46,16 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r
4646
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L22-L29" >}}
4747
{{< /tab >}}
4848
{{< tab header="Ruby" >}}
49-
{{< badge-code >}}
49+
{{< badge-implementation >}}
5050
{{< /tab >}}
5151
{{< tab header="Python" >}}
52-
{{< badge-code >}}
52+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L17-L21" >}}
5353
{{< /tab >}}
5454
{{< tab header="JavaScript" >}}
55-
{{< badge-code >}}
55+
{{< badge-implementation >}}
5656
{{< /tab >}}
5757
{{< tab header="Kotlin" >}}
58-
{{< badge-code >}}
58+
{{< badge-implementation >}}
5959
{{< /tab >}}
6060
{{< /tabpane >}}
6161

@@ -70,16 +70,16 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap
7070
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L32-L38" >}}
7171
{{< /tab >}}
7272
{{< tab header="Ruby" >}}
73-
{{< badge-code >}}
73+
{{< badge-implementation >}}
7474
{{< /tab >}}
7575
{{< tab header="Python" >}}
76-
{{< badge-code >}}
76+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L23-L27" >}}
7777
{{< /tab >}}
7878
{{< tab header="JavaScript" >}}
79-
{{< badge-code >}}
79+
{{< badge-implementation >}}
8080
{{< /tab >}}
8181
{{< tab header="Kotlin" >}}
82-
{{< badge-code >}}
82+
{{< badge-implementation >}}
8383
{{< /tab >}}
8484
{{< /tabpane >}}
8585

@@ -94,16 +94,16 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi
9494
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L51-L57" >}}
9595
{{< /tab >}}
9696
{{< tab header="Ruby" >}}
97-
{{< badge-code >}}
97+
{{< badge-implementation >}}
9898
{{< /tab >}}
9999
{{< tab header="Python" >}}
100-
{{< badge-code >}}
100+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L29-L39" >}}
101101
{{< /tab >}}
102102
{{< tab header="JavaScript" >}}
103-
{{< badge-code >}}
103+
{{< badge-implementation >}}
104104
{{< /tab >}}
105105
{{< tab header="Kotlin" >}}
106-
{{< badge-code >}}
106+
{{< badge-implementation >}}
107107
{{< /tab >}}
108108
{{< /tabpane >}}
109109

@@ -118,16 +118,16 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa
118118
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L61-L68" >}}
119119
{{< /tab >}}
120120
{{< tab header="Ruby" >}}
121-
{{< badge-code >}}
121+
{{< badge-implementation >}}
122122
{{< /tab >}}
123123
{{< tab header="Python" >}}
124-
{{< badge-code >}}
124+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L41-L46" >}}
125125
{{< /tab >}}
126126
{{< tab header="JavaScript" >}}
127-
{{< badge-code >}}
127+
{{< badge-implementation >}}
128128
{{< /tab >}}
129129
{{< tab header="Kotlin" >}}
130-
{{< badge-code >}}
130+
{{< badge-implementation >}}
131131
{{< /tab >}}
132132
{{< /tabpane >}}
133133

@@ -142,16 +142,16 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b
142142
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L41-L48" >}}
143143
{{< /tab >}}
144144
{{< tab header="Ruby" >}}
145-
{{< badge-code >}}
145+
{{< badge-implementation >}}
146146
{{< /tab >}}
147147
{{< tab header="Python" >}}
148-
{{< badge-code >}}
148+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L48-L52" >}}
149149
{{< /tab >}}
150150
{{< tab header="JavaScript" >}}
151-
{{< badge-code >}}
151+
{{< badge-implementation >}}
152152
{{< /tab >}}
153153
{{< tab header="Kotlin" >}}
154-
{{< badge-code >}}
154+
{{< badge-implementation >}}
155155
{{< /tab >}}
156156
{{< /tabpane >}}
157157

@@ -166,15 +166,15 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether t
166166
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L71-L78" >}}
167167
{{< /tab >}}
168168
{{< tab header="Ruby" >}}
169-
{{< badge-code >}}
169+
{{< badge-implementation >}}
170170
{{< /tab >}}
171171
{{< tab header="Python" >}}
172-
{{< badge-code >}}
172+
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L54-L58" >}}
173173
{{< /tab >}}
174174
{{< tab header="JavaScript" >}}
175-
{{< badge-code >}}
175+
{{< badge-implementation >}}
176176
{{< /tab >}}
177177
{{< tab header="Kotlin" >}}
178-
{{< badge-code >}}
178+
{{< badge-implementation >}}
179179
{{< /tab >}}
180180
{{< /tabpane >}}

0 commit comments

Comments
 (0)