Skip to content

Commit 74a93be

Browse files
authored
Merge pull request #562 from seleniumbase/crumbs-option
Add option to delete all cookies between tests that reuse sessions
2 parents c7af8ac + 68f722e commit 74a93be

File tree

7 files changed

+24
-13
lines changed

7 files changed

+24
-13
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,11 @@ SeleniumBase provides additional Pytest command-line options for tests:
243243
--disable-csp # (This disables the Content Security Policy of websites.)
244244
--enable-sync # (The option to enable "Chrome Sync".)
245245
--use-auto-ext # (The option to use Chrome's automation extension.)
246-
--no-sandbox # (The option to enable Chrome's "No-Sandbox" feature.)
247-
--disable-gpu # (The option to enable Chrome's "Disable GPU" feature.)
248246
--incognito # (The option to enable Chrome's Incognito mode.)
249247
--guest # (The option to enable Chrome's Guest mode.)
250248
--devtools # (The option to open Chrome's DevTools when the browser opens.)
251249
--reuse-session # (The option to reuse the browser session between tests.)
250+
--crumbs # (Option to delete all cookies between tests reusing a session.)
252251
--maximize-window # (The option to start with the web browser maximized.)
253252
--save-screenshot # (The option to save a screenshot after each test.)
254253
--visual-baseline # (Set the visual baseline for Visual/Layout tests.)

examples/raw_parameter_script.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
sb.no_sandbox = False
5252
sb.disable_gpu = False
5353
sb._reuse_session = False
54+
sb._crumbs = False
5455
sb.visual_baseline = False
5556
sb.maximize_option = False
5657
sb.save_screenshot_after_test = False

help_docs/customizing_test_runs.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,11 @@ SeleniumBase provides additional Pytest command-line options for tests:
116116
--disable-csp # (This disables the Content Security Policy of websites.)
117117
--enable-sync # (The option to enable "Chrome Sync".)
118118
--use-auto-ext # (The option to use Chrome's automation extension.)
119-
--no-sandbox # (The option to enable Chrome's "No-Sandbox" feature.)
120-
--disable-gpu # (The option to enable Chrome's "Disable GPU" feature.)
121119
--incognito # (The option to enable Chrome's Incognito mode.)
122120
--guest # (The option to enable Chrome's Guest mode.)
123121
--devtools # (The option to open Chrome's DevTools when the browser opens.)
124122
--reuse-session # (The option to reuse the browser session between tests.)
123+
--crumbs # (Option to delete all cookies between tests reusing a session.)
125124
--maximize-window # (The option to start with the web browser maximized.)
126125
--save-screenshot # (The option to save a screenshot after each test.)
127126
--visual-baseline # (Set the visual baseline for Visual/Layout tests.)

seleniumbase/fixtures/base_case.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4651,6 +4651,7 @@ def setUp(self, masterqa_mode=False):
46514651
self.extension_dir = sb_config.extension_dir
46524652
self.maximize_option = sb_config.maximize_option
46534653
self._reuse_session = sb_config.reuse_session
4654+
self._crumbs = sb_config.crumbs
46544655
self.save_screenshot_after_test = sb_config.save_screenshot
46554656
self.visual_baseline = sb_config.visual_baseline
46564657
self.timeout_multiplier = sb_config.timeout_multiplier
@@ -4773,6 +4774,8 @@ def setUp(self, masterqa_mode=False):
47734774
url = self.get_current_url()
47744775
if len(url) > 3:
47754776
has_url = True
4777+
if self._crumbs:
4778+
self.driver.delete_all_cookies()
47764779
except Exception:
47774780
pass
47784781
if self._reuse_session and sb_config.shared_driver and has_url:

seleniumbase/plugins/pytest_plugin.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ def pytest_addoption(parser):
4646
--disable-csp (This disables the Content Security Policy of websites.)
4747
--enable-sync (The option to enable "Chrome Sync".)
4848
--use-auto-ext (The option to use Chrome's automation extension.)
49-
--no-sandbox (The option to enable Chrome's "No-Sandbox" feature.)
50-
--disable-gpu (The option to enable Chrome's "Disable GPU" feature.)
5149
--incognito (The option to enable Chrome's Incognito mode.)
5250
--guest (The option to enable Chrome's Guest mode.)
5351
--devtools (The option to open Chrome's DevTools when the browser opens.)
5452
--reuse-session (The option to reuse the browser session between tests.)
53+
--crumbs (Option to delete all cookies between tests reusing a session.)
5554
--maximize (The option to start with the web browser maximized.)
5655
--save-screenshot (The option to save a screenshot after each test.)
5756
--visual-baseline (Set the visual baseline for Visual/Layout tests.)
@@ -363,12 +362,14 @@ def pytest_addoption(parser):
363362
action="store_true",
364363
dest='no_sandbox',
365364
default=False,
366-
help="""Using this enables the "No Sandbox" feature.""")
365+
help="""Using this enables the "No Sandbox" feature.
366+
(This setting is now always enabled by default.)""")
367367
parser.addoption('--disable_gpu', '--disable-gpu',
368368
action="store_true",
369369
dest='disable_gpu',
370370
default=False,
371-
help="""Using this enables the "Disable GPU" feature.""")
371+
help="""Using this enables the "Disable GPU" feature.
372+
(This setting is now always enabled by default.)""")
372373
parser.addoption('--incognito', '--incognito_mode', '--incognito-mode',
373374
action="store_true",
374375
dest='incognito',
@@ -390,6 +391,13 @@ def pytest_addoption(parser):
390391
default=False,
391392
help="""The option to reuse the selenium browser window
392393
session between tests.""")
394+
parser.addoption('--crumbs',
395+
action="store_true",
396+
dest='crumbs',
397+
default=False,
398+
help="""The option to delete all cookies between tests
399+
that reuse the same browser session. This option
400+
is only needed when using "--reuse-session".""")
393401
parser.addoption('--maximize_window', '--maximize-window', '--maximize',
394402
'--fullscreen',
395403
action="store_true",
@@ -478,6 +486,7 @@ def pytest_configure(config):
478486
sb_config.guest_mode = config.getoption('guest_mode')
479487
sb_config.devtools = config.getoption('devtools')
480488
sb_config.reuse_session = config.getoption('reuse_session')
489+
sb_config.crumbs = config.getoption('crumbs')
481490
sb_config.shared_driver = None # The default driver for session reuse
482491
sb_config.maximize_option = config.getoption('maximize_option')
483492
sb_config.save_screenshot = config.getoption('save_screenshot')

seleniumbase/plugins/selenium_plugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ class SeleniumBrowser(Plugin):
3737
--disable-csp (This disables the Content Security Policy of websites.)
3838
--enable-sync (The option to enable "Chrome Sync".)
3939
--use-auto-ext (The option to use Chrome's automation extension.)
40-
--no-sandbox (The option to enable Chrome's "No-Sandbox" feature.)
41-
--disable-gpu (The option to enable Chrome's "Disable GPU" feature.)
4240
--incognito (The option to enable Chrome's Incognito mode.)
4341
--guest (The option to enable Chrome's Guest mode.)
4442
--devtools (The option to open Chrome's DevTools when the browser opens.)
@@ -279,13 +277,15 @@ def options(self, parser, env):
279277
action="store_true",
280278
dest='no_sandbox',
281279
default=False,
282-
help="""Using this enables the "No Sandbox" feature.""")
280+
help="""Using this enables the "No Sandbox" feature.
281+
(This setting is now always enabled by default.)""")
283282
parser.add_option(
284283
'--disable_gpu', '--disable-gpu',
285284
action="store_true",
286285
dest='disable_gpu',
287286
default=False,
288-
help="""Using this enables the "Disable GPU" feature.""")
287+
help="""Using this enables the "Disable GPU" feature.
288+
(This setting is now always enabled by default.)""")
289289
parser.add_option(
290290
'--incognito', '--incognito_mode', '--incognito-mode',
291291
action="store_true",

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
setup(
4949
name='seleniumbase',
50-
version='1.37.13',
50+
version='1.37.14',
5151
description='Fast, Easy, and Reliable Browser Automation & Testing.',
5252
long_description=long_description,
5353
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)