-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathtest_print_options.py
58 lines (50 loc) · 1.91 KB
/
test_print_options.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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.page_height = 27.94 # Use page_width to assign width
assert print_options.page_height == 27.94
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