Skip to content

Commit

Permalink
Merge pull request #3177 from seleniumbase/fix-xvfb-settings-and-refa…
Browse files Browse the repository at this point in the history
…ctor

Fix Xvfb settings and refactor
  • Loading branch information
mdmintz authored Oct 4, 2024
2 parents fc3c75d + 5e40d59 commit e17ce80
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 15 deletions.
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ typing-extensions>=4.12.2
sbvirtualdisplay>=1.3.0
six>=1.16.0
parse>=1.20.2
parse-type>=0.6.3
parse-type>=0.6.4
colorama>=0.4.6
pyyaml>=6.0.2
pygments>=2.18.0
Expand Down Expand Up @@ -55,7 +55,7 @@ pyotp==2.9.0
python-xlib==0.33;platform_system=="Linux"
markdown-it-py==3.0.0
mdurl==0.1.2
rich==13.9.1
rich==13.9.2

# --- Testing Requirements --- #
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)
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__ = "4.31.3"
__version__ = "4.31.4"
8 changes: 4 additions & 4 deletions seleniumbase/behave/behave_sb.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,12 @@ def get_configured_sb(context):
if low_key in ["disable-js", "disable_js"]:
sb.disable_js = True
continue
# Handle: -D disable-csp / disable_csp
if low_key in ["disable-csp", "disable_csp"]:
# Handle: -D disable-csp / disable_csp / dcsp
if low_key in ["disable-csp", "disable_csp", "dcsp"]:
sb.disable_csp = True
continue
# Handle: -D disable-ws / disable_ws
if low_key in ["disable-ws", "disable_ws"]:
# Handle: -D disable-ws / disable_ws / dws
if low_key in ["disable-ws", "disable_ws", "dws"]:
sb.disable_ws = True
continue
# Handle: -D enable-ws / enable_ws
Expand Down
10 changes: 6 additions & 4 deletions seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -14500,15 +14500,13 @@ def setUp(self, masterqa_mode=False):
self.__skip_reason = None
self.testcase_manager.insert_testcase_data(data_payload)
self.case_start_time = int(time.time() * 1000.0)
self.__activate_virtual_display_as_needed()
elif hasattr(self, "is_behave") and self.is_behave:
self.__initialize_variables()
self.__activate_virtual_display_as_needed()
elif hasattr(self, "is_nosetest") and self.is_nosetest:
pass # Setup performed in plugins for pynose
else:
# Pure Python run. Eg. SB() Manager
self.__activate_virtual_display_as_needed()
# Pure Python run. (Eg. SB() and Driver() Managers)
pass # Variables initialized in respective plugins

# Verify SeleniumBase is installed successfully, and used correctly
if not hasattr(self, "browser"):
Expand Down Expand Up @@ -14696,6 +14694,10 @@ def setUp(self, masterqa_mode=False):
)
raise Exception(message)

if not hasattr(self, "is_nosetest") or not self.is_nosetest:
# Xvfb Virtual Display activation for Linux
self.__activate_virtual_display_as_needed()

# Dashboard pre-processing:
if self.dashboard:
if self._multithreaded:
Expand Down
18 changes: 17 additions & 1 deletion seleniumbase/plugins/driver_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,24 @@ def Driver(
elif browser not in ["chrome", "edge"]:
headless2 = False # Only for Chromium browsers
if disable_csp is None:
disable_csp = False
if (
"--disable-csp" in sys_argv
or "--no-csp" in sys_argv
or "--dcsp" in sys_argv
):
disable_csp = True
else:
disable_csp = False
if (
(enable_ws is None and disable_ws is None)
and (
"--disable-web-security" in sys_argv
or "--disable-ws" in sys_argv
or "--dws" in sys_argv
)
):
enable_ws = False
elif (
(enable_ws is None and disable_ws is None)
or (disable_ws is not None and not disable_ws)
or (enable_ws is not None and enable_ws)
Expand Down
1 change: 1 addition & 0 deletions seleniumbase/plugins/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ def pytest_addoption(parser):
parser.addoption(
"--disable_ws",
"--disable-ws",
"--dws",
"--disable-web-security",
action="store_true",
dest="disable_ws",
Expand Down
19 changes: 18 additions & 1 deletion seleniumbase/plugins/sb_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,25 @@ def SB(
else:
variables = {}
if disable_csp is None:
disable_csp = False
if (
"--disable-csp" in sys_argv
or "--no-csp" in sys_argv
or "--dcsp" in sys_argv
):
disable_csp = True
else:
disable_csp = False
if (
(enable_ws is None and disable_ws is None)
and (
"--disable-web-security" in sys_argv
or "--disable-ws" in sys_argv
or "--dws" in sys_argv
)
):
enable_ws = False
disable_ws = True
elif (
(enable_ws is None and disable_ws is None)
or (disable_ws is not None and not disable_ws)
or (enable_ws is not None and enable_ws)
Expand Down
1 change: 1 addition & 0 deletions seleniumbase/plugins/selenium_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ def options(self, parser, env):
parser.addoption(
"--disable_ws",
"--disable-ws",
"--dws",
"--disable-web-security",
action="store_true",
dest="disable_ws",
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
"sbvirtualdisplay>=1.3.0",
"six>=1.16.0",
'parse>=1.20.2',
'parse-type>=0.6.3',
'parse-type>=0.6.4',
'colorama>=0.4.6',
'pyyaml>=6.0.2',
'pygments>=2.18.0',
Expand Down Expand Up @@ -204,7 +204,7 @@
'python-xlib==0.33;platform_system=="Linux"',
'markdown-it-py==3.0.0',
'mdurl==0.1.2',
'rich==13.9.1',
'rich==13.9.2',
],
extras_require={
# pip install -e .[allure]
Expand Down

0 comments on commit e17ce80

Please sign in to comment.