Add "--external-pdf" option to open PDFs externally
This commit is contained in:
parent
a6c60686ce
commit
338f28d60b
|
@ -82,6 +82,7 @@ if pure_python:
|
|||
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
|
||||
|
|
|
@ -273,6 +273,7 @@ def _set_chrome_options(
|
|||
user_data_dir,
|
||||
extension_zip,
|
||||
extension_dir,
|
||||
external_pdf,
|
||||
servername,
|
||||
mobile_emulator,
|
||||
device_width,
|
||||
|
@ -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:
|
||||
|
@ -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,
|
||||
|
@ -803,6 +807,7 @@ def get_driver(
|
|||
user_data_dir,
|
||||
extension_zip,
|
||||
extension_dir,
|
||||
external_pdf,
|
||||
test_id,
|
||||
mobile_emulator,
|
||||
device_width,
|
||||
|
@ -841,6 +846,7 @@ def get_driver(
|
|||
user_data_dir,
|
||||
extension_zip,
|
||||
extension_dir,
|
||||
external_pdf,
|
||||
mobile_emulator,
|
||||
device_width,
|
||||
device_height,
|
||||
|
@ -883,6 +889,7 @@ def get_remote_driver(
|
|||
user_data_dir,
|
||||
extension_zip,
|
||||
extension_dir,
|
||||
external_pdf,
|
||||
test_id,
|
||||
mobile_emulator,
|
||||
device_width,
|
||||
|
@ -971,6 +978,7 @@ def get_remote_driver(
|
|||
user_data_dir,
|
||||
extension_zip,
|
||||
extension_dir,
|
||||
external_pdf,
|
||||
servername,
|
||||
mobile_emulator,
|
||||
device_width,
|
||||
|
@ -1298,6 +1306,7 @@ def get_local_driver(
|
|||
user_data_dir,
|
||||
extension_zip,
|
||||
extension_dir,
|
||||
external_pdf,
|
||||
mobile_emulator,
|
||||
device_width,
|
||||
device_height,
|
||||
|
@ -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(
|
||||
|
@ -1738,6 +1749,7 @@ def get_local_driver(
|
|||
user_data_dir,
|
||||
extension_zip,
|
||||
extension_dir,
|
||||
external_pdf,
|
||||
servername,
|
||||
mobile_emulator,
|
||||
device_width,
|
||||
|
@ -1791,6 +1803,7 @@ def get_local_driver(
|
|||
user_data_dir,
|
||||
extension_zip,
|
||||
extension_dir,
|
||||
external_pdf,
|
||||
servername,
|
||||
mobile_emulator,
|
||||
device_width,
|
||||
|
@ -1888,6 +1901,7 @@ def get_local_driver(
|
|||
user_data_dir,
|
||||
extension_zip,
|
||||
extension_dir,
|
||||
external_pdf,
|
||||
servername,
|
||||
mobile_emulator,
|
||||
device_width,
|
||||
|
|
|
@ -2762,6 +2762,7 @@ class BaseCase(unittest.TestCase):
|
|||
user_data_dir=None,
|
||||
extension_zip=None,
|
||||
extension_dir=None,
|
||||
external_pdf=None,
|
||||
is_mobile=None,
|
||||
d_width=None,
|
||||
d_height=None,
|
||||
|
@ -2803,6 +2804,7 @@ class BaseCase(unittest.TestCase):
|
|||
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)
|
||||
|
@ -2899,6 +2901,8 @@ class BaseCase(unittest.TestCase):
|
|||
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
|
||||
|
@ -2954,6 +2958,7 @@ class BaseCase(unittest.TestCase):
|
|||
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,
|
||||
|
@ -10899,6 +10904,7 @@ class BaseCase(unittest.TestCase):
|
|||
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
|
||||
|
@ -11159,6 +11165,7 @@ class BaseCase(unittest.TestCase):
|
|||
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,
|
||||
|
|
|
@ -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 = ""
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
|
|
|
@ -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.)
|
||||
"""
|
||||
|
||||
|
@ -585,8 +586,7 @@ class SeleniumBrowser(Plugin):
|
|||
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(
|
||||
|
@ -600,6 +600,17 @@ class SeleniumBrowser(Plugin):
|
|||
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",
|
||||
|
@ -677,6 +688,7 @@ class SeleniumBrowser(Plugin):
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue