-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add Python Examples for PrintOptions #1994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
shbenzer
wants to merge
4
commits into
SeleniumHQ:trunk
from
shbenzer:Add-Python-Examples-for-printOptions
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e830d58
Added Python Examples for PrintOptions
shbenzer d808dbd
changed missing example badgecodes to implementation missing badge codes
shbenzer 1a84559
Merge branch 'trunk' into Add-Python-Examples-for-printOptions
harsha509 7b8b226
fixed tests
shbenzer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
examples/python/tests/interactions/test_print_options.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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-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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.