Skip to content

Commit

Permalink
Added Python Examples for PrintOptions() (#2000)[deploy site]
Browse files Browse the repository at this point in the history
* Added Python Examples for PrintOptions()

* fixed assertion error

* now the assertion error is fixed

---------

Co-authored-by: Sri Harsha <[email protected]>
  • Loading branch information
shbenzer and harsha509 authored Oct 16, 2024
1 parent 7391ac0 commit 6703150
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 112 deletions.
58 changes: 58 additions & 0 deletions examples/python/tests/interactions/test_print_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import pytest
from selenium import webdriver
from selenium.webdriver.common.print_page_options import PrintOptions

@pytest.fixture()
def driver():
driver = webdriver.Chrome()
yield driver
driver.quit()

def test_orientation(driver):
driver.get("https://www.selenium.dev/")
print_options = PrintOptions()
print_options.orientation = "landscape" ## landscape or portrait
assert print_options.orientation == "landscape"

def test_range(driver):
driver.get("https://www.selenium.dev/")
print_options = PrintOptions()
print_options.page_ranges = ["1, 2, 3"] ## ["1", "2", "3"] or ["1-3"]
assert print_options.page_ranges == ["1, 2, 3"]

def test_size(driver):
driver.get("https://www.selenium.dev/")
print_options = PrintOptions()
print_options.scale = 0.5 ## 0.1 to 2.0``
assert print_options.scale == 0.5

def test_margin(driver):
driver.get("https://www.selenium.dev/")
print_options = PrintOptions()
print_options.margin_top = 10
print_options.margin_bottom = 10
print_options.margin_left = 10
print_options.margin_right = 10
assert print_options.margin_top == 10
assert print_options.margin_bottom == 10
assert print_options.margin_left == 10
assert print_options.margin_right == 10

def test_scale(driver):
driver.get("https://www.selenium.dev/")
print_options = PrintOptions()
print_options.scale = 0.5 ## 0.1 to 2.0
current_scale = print_options.scale
assert current_scale == 0.5

def test_background(driver):
driver.get("https://www.selenium.dev/")
print_options = PrintOptions()
print_options.background = True ## True or False
assert print_options.background is True

def test_shrink_to_fit(driver):
driver.get("https://www.selenium.dev/")
print_options = PrintOptions()
print_options.shrink_to_fit = True ## True or False
assert print_options.shrink_to_fit is True
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L12-L19" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L11-L15" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}

Expand All @@ -46,16 +46,16 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L22-L29" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L17-L21" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}

Expand All @@ -70,16 +70,16 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L32-L38" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L23-L27" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}

Expand All @@ -94,16 +94,16 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L51-L57" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L29-L39" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}

Expand All @@ -118,16 +118,16 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L61-L68" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L41-L46" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}

Expand All @@ -142,16 +142,16 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L41-L48" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L48-L52" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}

Expand All @@ -166,15 +166,15 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether t
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L71-L78" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L54-L58" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ Using the `getOrientation()` and `setOrientation()` methods, you can get/set the
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L12-L19" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L11-L15" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}

Expand All @@ -46,16 +46,16 @@ Using the `getPageRanges()` and `setPageRanges()` methods, you can get/set the r
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L22-L29" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L17-L21" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}

Expand All @@ -70,16 +70,16 @@ Using the `getPaperSize()` and `setPaperSize()` methods, you can get/set the pap
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L32-L38" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L23-L27" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}

Expand All @@ -94,16 +94,16 @@ Using the `getPageMargin()` and `setPageMargin()` methods, you can set the margi
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L51-L57" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L29-L39" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}

Expand All @@ -118,16 +118,16 @@ Using `getScale()` and `setScale()` methods, you can get/set the scale of the pa
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L61-L68" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L41-L46" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}

Expand All @@ -142,16 +142,16 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether b
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L41-L48" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L48-L52" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}

Expand All @@ -166,15 +166,15 @@ Using `getBackground()` and `setBackground()` methods, you can get/set whether t
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/PrintOptionsTest.cs#L71-L78" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/python/tests/interactions/test_print_options.py#L54-L58" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< tab header="Kotlin" >}}
{{< badge-code >}}
{{< badge-implementation >}}
{{< /tab >}}
{{< /tabpane >}}
Loading

0 comments on commit 6703150

Please sign in to comment.