Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ The code above will leave your browser window open in case there's a failure. (i
--maximize-window # (Start tests with the web browser window maximized.)
--save-screenshot # (Save a screenshot at the end of each test.)
--visual-baseline # (Set the visual baseline for Visual/Layout tests.)
--external-pdf # (Set Chrome "plugins.always_open_pdf_externally": True.)
--timeout-multiplier=MULTIPLIER # (Multiplies the default timeout values.)
```

Expand Down
1 change: 1 addition & 0 deletions examples/raw_parameter_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
sb._dash_initialized = False
sb.message_duration = 2
sb.block_images = False
sb.external_pdf = False
sb.remote_debug = False
sb.settings_file = None
sb.user_data_dir = None
Expand Down
1 change: 1 addition & 0 deletions help_docs/customizing_test_runs.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ SeleniumBase provides additional ``pytest`` command-line options for tests:
--maximize-window # (Start tests with the web browser window maximized.)
--save-screenshot # (Save a screenshot at the end of each test.)
--visual-baseline # (Set the visual baseline for Visual/Layout tests.)
--external-pdf # (Set Chrome "plugins.always_open_pdf_externally": True.)
--timeout-multiplier=MULTIPLIER # (Multiplies the default timeout values.)
```

Expand Down
4 changes: 2 additions & 2 deletions mkdocs_build/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ livereload==2.6.3;python_version>="3.6"
joblib==1.1.0;python_version>="3.6"
Markdown==3.3.6;python_version>="3.6"
MarkupSafe==2.0.1;python_version>="3.6"
pyparsing==3.0.6;python_version>="3.6"
pyparsing==3.0.7;python_version>="3.6"
keyring==23.5.0;python_version>="3.7"
pkginfo==1.8.2;python_version>="3.6"
Jinja2==3.0.3;python_version>="3.6"
Expand All @@ -21,7 +21,7 @@ lunr==0.6.1;python_version>="3.6"
nltk==3.6.7;python_version>="3.6"
watchdog==2.1.6;python_version>="3.6"
mkdocs==1.2.3;python_version>="3.6"
mkdocs-material==8.1.7;python_version>="3.6"
mkdocs-material==8.1.8;python_version>="3.6"
mkdocs-exclude-search==0.6.4;python_version>="3.6"
mkdocs-simple-hooks==0.1.5
mkdocs-material-extensions==1.0.3;python_version>="3.6"
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ decorator==5.1.1;python_version>="3.5"
ipython==5.10.0;python_version<"3.5"
ipython==7.9.0;python_version>="3.5" and python_version<"3.6"
ipython==7.16.1;python_version>="3.6" and python_version<"3.7"
ipython==7.31.0;python_version>="3.7"
ipython==7.31.1;python_version>="3.7"
matplotlib-inline==0.1.3;python_version>="3.7"
colorama==0.4.4
platformdirs==2.0.2;python_version<"3.6"
Expand Down Expand Up @@ -135,6 +135,7 @@ pytest-cov==3.0.0;python_version>="3.6"
flake8==3.7.9;python_version<"3.5"
flake8==3.9.2;python_version>="3.5" and python_version<"3.6"
flake8==4.0.1;python_version>="3.6"
mccabe==0.6.1
pyflakes==2.1.1;python_version<"3.5"
pyflakes==2.3.1;python_version>="3.5" and python_version<"3.6"
pyflakes==2.4.0;python_version>="3.6"
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "2.4.0"
__version__ = "2.4.1"
14 changes: 14 additions & 0 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def _set_chrome_options(
user_data_dir,
extension_zip,
extension_dir,
external_pdf,
servername,
mobile_emulator,
device_width,
Expand Down Expand Up @@ -302,6 +303,8 @@ def _set_chrome_options(
prefs["intl.accept_languages"] = locale_code
if block_images:
prefs["profile.managed_default_content_settings.images"] = 2
if external_pdf:
prefs["plugins.always_open_pdf_externally"] = True
chrome_options.add_experimental_option("prefs", prefs)
chrome_options.add_experimental_option("w3c", True)
if enable_sync:
Expand Down Expand Up @@ -728,6 +731,7 @@ def get_driver(
user_data_dir=None,
extension_zip=None,
extension_dir=None,
external_pdf=None,
test_id=None,
mobile_emulator=False,
device_width=None,
Expand Down Expand Up @@ -803,6 +807,7 @@ def get_driver(
user_data_dir,
extension_zip,
extension_dir,
external_pdf,
test_id,
mobile_emulator,
device_width,
Expand Down Expand Up @@ -841,6 +846,7 @@ def get_driver(
user_data_dir,
extension_zip,
extension_dir,
external_pdf,
mobile_emulator,
device_width,
device_height,
Expand Down Expand Up @@ -883,6 +889,7 @@ def get_remote_driver(
user_data_dir,
extension_zip,
extension_dir,
external_pdf,
test_id,
mobile_emulator,
device_width,
Expand Down Expand Up @@ -971,6 +978,7 @@ def get_remote_driver(
user_data_dir,
extension_zip,
extension_dir,
external_pdf,
servername,
mobile_emulator,
device_width,
Expand Down Expand Up @@ -1298,6 +1306,7 @@ def get_local_driver(
user_data_dir,
extension_zip,
extension_dir,
external_pdf,
mobile_emulator,
device_width,
device_height,
Expand Down Expand Up @@ -1490,6 +1499,8 @@ def get_local_driver(
prefs["intl.accept_languages"] = locale_code
if block_images:
prefs["profile.managed_default_content_settings.images"] = 2
if external_pdf:
prefs["plugins.always_open_pdf_externally"] = True
edge_options.add_experimental_option("prefs", prefs)
edge_options.add_experimental_option("w3c", True)
edge_options.add_argument(
Expand Down Expand Up @@ -1738,6 +1749,7 @@ def get_local_driver(
user_data_dir,
extension_zip,
extension_dir,
external_pdf,
servername,
mobile_emulator,
device_width,
Expand Down Expand Up @@ -1791,6 +1803,7 @@ def get_local_driver(
user_data_dir,
extension_zip,
extension_dir,
external_pdf,
servername,
mobile_emulator,
device_width,
Expand Down Expand Up @@ -1888,6 +1901,7 @@ def get_local_driver(
user_data_dir,
extension_zip,
extension_dir,
external_pdf,
servername,
mobile_emulator,
device_width,
Expand Down
7 changes: 7 additions & 0 deletions seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -2762,6 +2762,7 @@ def get_new_driver(
user_data_dir=None,
extension_zip=None,
extension_dir=None,
external_pdf=None,
is_mobile=None,
d_width=None,
d_height=None,
Expand Down Expand Up @@ -2803,6 +2804,7 @@ def get_new_driver(
user_data_dir - Chrome's User Data Directory to use (Chrome-only)
extension_zip - A Chrome Extension ZIP file to use (Chrome-only)
extension_dir - A Chrome Extension folder to use (Chrome-only)
external_pdf - "plugins.always_open_pdf_externally": True. (Chrome)
is_mobile - the option to use the mobile emulator (Chrome-only)
d_width - the device width of the mobile emulator (Chrome-only)
d_height - the device height of the mobile emulator (Chrome-only)
Expand Down Expand Up @@ -2899,6 +2901,8 @@ def get_new_driver(
extension_zip = self.extension_zip
if extension_dir is None:
extension_dir = self.extension_dir
if external_pdf is None:
external_pdf = self.external_pdf
test_id = self.__get_test_id()
if cap_file is None:
cap_file = self.cap_file
Expand Down Expand Up @@ -2954,6 +2958,7 @@ def get_new_driver(
user_data_dir=user_data_dir,
extension_zip=extension_zip,
extension_dir=extension_dir,
external_pdf=external_pdf,
test_id=test_id,
mobile_emulator=is_mobile,
device_width=d_width,
Expand Down Expand Up @@ -10899,6 +10904,7 @@ def setUp(self, masterqa_mode=False):
self.user_data_dir = sb_config.user_data_dir
self.extension_zip = sb_config.extension_zip
self.extension_dir = sb_config.extension_dir
self.external_pdf = sb_config.external_pdf
self.maximize_option = sb_config.maximize_option
self.save_screenshot_after_test = sb_config.save_screenshot
self.visual_baseline = sb_config.visual_baseline
Expand Down Expand Up @@ -11159,6 +11165,7 @@ def setUp(self, masterqa_mode=False):
user_data_dir=self.user_data_dir,
extension_zip=self.extension_zip,
extension_dir=self.extension_dir,
external_pdf=self.external_pdf,
is_mobile=self.mobile_emulator,
d_width=self.__device_width,
d_height=self.__device_height,
Expand Down
21 changes: 17 additions & 4 deletions seleniumbase/plugins/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def pytest_addoption(parser):
--maximize (Start tests with the web browser window maximized.)
--save-screenshot (Save a screenshot at the end of each test.)
--visual-baseline (Set the visual baseline for Visual/Layout tests.)
--external-pdf (Set Chromium "plugins.always_open_pdf_externally": True.)
--timeout-multiplier=MULTIPLIER (Multiplies the default timeout values.)
"""
c1 = ""
Expand Down Expand Up @@ -831,8 +832,8 @@ def pytest_addoption(parser):
dest="crumbs",
default=False,
help="""The option to delete all cookies between tests
that reuse the same browser session. This option
is only needed when using "--reuse-session".""",
that reuse the same browser session. This option
is only needed when using "--reuse-session".""",
)
parser.addoption(
"--maximize_window",
Expand All @@ -853,8 +854,8 @@ def pytest_addoption(parser):
action="store_true",
dest="save_screenshot",
default=False,
help="""Take a screenshot on last page after the last step
of the test. (Added to the "latest_logs" folder.)""",
help="""Save a screenshot at the end of the test.
(Added to the "latest_logs/" folder.)""",
)
parser.addoption(
"--visual_baseline",
Expand All @@ -867,6 +868,17 @@ def pytest_addoption(parser):
When a test calls self.check_window(), it will
rebuild its files in the visual_baseline folder.""",
)
parser.addoption(
"--external_pdf",
"--external-pdf",
action="store_true",
dest="external_pdf",
default=False,
help="""This option sets the following on Chromium:
"plugins.always_open_pdf_externally": True,
which causes opened PDF URLs to download immediately,
instead of being displayed in the browser window.""",
)
parser.addoption(
"--timeout_multiplier",
"--timeout-multiplier",
Expand Down Expand Up @@ -1114,6 +1126,7 @@ def pytest_configure(config):
sb_config.maximize_option = config.getoption("maximize_option")
sb_config.save_screenshot = config.getoption("save_screenshot")
sb_config.visual_baseline = config.getoption("visual_baseline")
sb_config.external_pdf = config.getoption("external_pdf")
sb_config.timeout_multiplier = config.getoption("timeout_multiplier")
sb_config._is_timeout_changed = False
sb_config._SMALL_TIMEOUT = settings.SMALL_TIMEOUT
Expand Down
16 changes: 14 additions & 2 deletions seleniumbase/plugins/selenium_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class SeleniumBrowser(Plugin):
--maximize (Start tests with the web browser window maximized.)
--save-screenshot (Save a screenshot at the end of each test.)
--visual-baseline (Set the visual baseline for Visual/Layout tests.)
--external-pdf (Set Chromium "plugins.always_open_pdf_externally": True.)
--timeout-multiplier=MULTIPLIER (Multiplies the default timeout values.)
"""

Expand Down Expand Up @@ -585,8 +586,7 @@ def options(self, parser, env):
action="store_true",
dest="save_screenshot",
default=False,
help="""(DEPRECATED) - Screenshots are enabled by default now.
This option saves screenshots during test failures.
help="""Save a screenshot at the end of the test.
(Added to the "latest_logs/" folder.)""",
)
parser.add_option(
Expand All @@ -600,6 +600,17 @@ def options(self, parser, env):
When a test calls self.check_window(), it will
rebuild its files in the visual_baseline folder.""",
)
parser.add_option(
"--external_pdf",
"--external-pdf",
action="store_true",
dest="external_pdf",
default=False,
help="""This option sets the following on Chromium:
"plugins.always_open_pdf_externally": True,
which causes opened PDF URLs to download immediately,
instead of being displayed in the browser window.""",
)
parser.add_option(
"--timeout_multiplier",
"--timeout-multiplier",
Expand Down Expand Up @@ -677,6 +688,7 @@ def beforeTest(self, test):
test.test.maximize_option = self.options.maximize_option
test.test.save_screenshot_after_test = self.options.save_screenshot
test.test.visual_baseline = self.options.visual_baseline
test.test.external_pdf = self.options.external_pdf
test.test.timeout_multiplier = self.options.timeout_multiplier
test.test.dashboard = False
test.test._multithreaded = False
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
'ipython==5.10.0;python_version<"3.5"',
'ipython==7.9.0;python_version>="3.5" and python_version<"3.6"',
'ipython==7.16.1;python_version>="3.6" and python_version<"3.7"',
'ipython==7.31.0;python_version>="3.7"', # Requires matplotlib-inline
'ipython==7.31.1;python_version>="3.7"', # Requires matplotlib-inline
'matplotlib-inline==0.1.3;python_version>="3.7"', # ipython needs this
"colorama==0.4.4",
'platformdirs==2.0.2;python_version<"3.6"',
Expand Down Expand Up @@ -263,6 +263,7 @@
'flake8==3.7.9;python_version<"3.5"',
'flake8==3.9.2;python_version>="3.5" and python_version<"3.6"',
'flake8==4.0.1;python_version>="3.6"',
'mccabe==0.6.1',
'pyflakes==2.1.1;python_version<"3.5"',
'pyflakes==2.3.1;python_version>="3.5" and python_version<"3.6"',
'pyflakes==2.4.0;python_version>="3.6"',
Expand Down