Skip to content

Commit 375e3d4

Browse files
committed
Add cmd option "--disable-ws". (Chrome Web Security)
1 parent 66c5933 commit 375e3d4

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

examples/raw_parameter_script.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
sb.log_path = "latest_logs/"
4848
sb.archive_logs = False
4949
sb.disable_csp = False
50+
sb.disable_ws = False
5051
sb.enable_ws = False
5152
sb.enable_sync = False
5253
sb.use_auto_ext = False

seleniumbase/fixtures/base_case.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6229,7 +6229,10 @@ def setUp(self, masterqa_mode=False):
62296229
self.block_images = sb_config.block_images
62306230
self.verify_delay = sb_config.verify_delay
62316231
self.disable_csp = sb_config.disable_csp
6232+
self.disable_ws = sb_config.disable_ws
62326233
self.enable_ws = sb_config.enable_ws
6234+
if not self.disable_ws:
6235+
self.enable_ws = True
62336236
self.enable_sync = sb_config.enable_sync
62346237
self.use_auto_ext = sb_config.use_auto_ext
62356238
self.no_sandbox = sb_config.no_sandbox

seleniumbase/plugins/pytest_plugin.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def pytest_addoption(parser):
4848
--block-images (Block images from loading during tests.)
4949
--verify-delay=SECONDS (The delay before MasterQA verification checks.)
5050
--disable-csp (Disable the Content Security Policy of websites.)
51-
--enable-ws (Enable Web Security on Chrome.)
51+
--disable-ws (Disable Web Security on Chromium-based browsers.)
52+
--enable-ws (Enable Web Security on Chromium-based browsers.)
5253
--enable-sync (Enable "Chrome Sync".)
5354
--use-auto-ext (Use Chrome's automation extension.)
5455
--swiftshader (Use Chrome's "--use-gl=swiftshader" feature.)
@@ -376,6 +377,12 @@ def pytest_addoption(parser):
376377
libraries for various testing actions.
377378
Setting this to True (--disable-csp) overrides the
378379
value set in seleniumbase/config/settings.py""")
380+
parser.addoption('--disable_ws', '--disable-ws', '--disable-web-security',
381+
action="store_true",
382+
dest='disable_ws',
383+
default=False,
384+
help="""Using this disables the "Web Security" feature of
385+
Chrome and Chromium-based browsers such as Edge.""")
379386
parser.addoption('--enable_ws', '--enable-ws', '--enable-web-security',
380387
action="store_true",
381388
dest='enable_ws',
@@ -523,7 +530,10 @@ def pytest_configure(config):
523530
sb_config.block_images = config.getoption('block_images')
524531
sb_config.verify_delay = config.getoption('verify_delay')
525532
sb_config.disable_csp = config.getoption('disable_csp')
533+
sb_config.disable_ws = config.getoption('disable_ws')
526534
sb_config.enable_ws = config.getoption('enable_ws')
535+
if not sb_config.disable_ws:
536+
sb_config.enable_ws = True
527537
sb_config.enable_sync = config.getoption('enable_sync')
528538
sb_config.use_auto_ext = config.getoption('use_auto_ext')
529539
sb_config.no_sandbox = config.getoption('no_sandbox')

seleniumbase/plugins/selenium_plugin.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ class SeleniumBrowser(Plugin):
3737
--ad-block (Block some types of display ads after page loads.)
3838
--block-images (Block images from loading during tests.)
3939
--verify-delay=SECONDS (The delay before MasterQA verification checks.)
40-
--disable-csp (This disables the Content Security Policy of websites.)
41-
--enable-ws (Enable Web Security on Chrome.)
40+
--disable-csp (Disable the Content Security Policy of websites.)
41+
--disable-ws (Disable Web Security on Chromium-based browsers.)
42+
--enable-ws (Enable Web Security on Chromium-based browsers.)
4243
--enable-sync (Enable "Chrome Sync".)
4344
--use-auto-ext (Use Chrome's automation extension.)
4445
--swiftshader (Use Chrome's "--use-gl=swiftshader" feature.)
@@ -280,6 +281,13 @@ def options(self, parser, env):
280281
libraries for various testing actions.
281282
Setting this to True (--disable-csp) overrides the
282283
value set in seleniumbase/config/settings.py""")
284+
parser.add_option(
285+
'--disable_ws', '--disable-ws', '--disable-web-security',
286+
action="store_true",
287+
dest='disable_ws',
288+
default=False,
289+
help="""Using this disables the "Web Security" feature of
290+
Chrome and Chromium-based browsers such as Edge.""")
283291
parser.add_option(
284292
'--enable_ws', '--enable-ws', '--enable-web-security',
285293
action="store_true",
@@ -407,7 +415,10 @@ def beforeTest(self, test):
407415
test.test.block_images = self.options.block_images
408416
test.test.verify_delay = self.options.verify_delay # MasterQA
409417
test.test.disable_csp = self.options.disable_csp
418+
test.test.disable_ws = self.options.disable_ws
410419
test.test.enable_ws = self.options.enable_ws
420+
if not self.options.disable_ws:
421+
test.test.enable_ws = True
411422
test.test.enable_sync = self.options.enable_sync
412423
test.test.use_auto_ext = self.options.use_auto_ext
413424
test.test.no_sandbox = self.options.no_sandbox

0 commit comments

Comments
 (0)