Skip to content

Commit 072b93e

Browse files
committed
Add the "--interval=SECONDS" option for autoplaying tour steps
1 parent b11211f commit 072b93e

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3976,6 +3976,8 @@ def save_presentation(
39763976
raise Exception('Presentation file must end in ".html"!')
39773977
if not interval:
39783978
interval = 0
3979+
if interval == 0 and self.interval:
3980+
interval = float(self.interval)
39793981
if not type(interval) is int and not type(interval) is float:
39803982
raise Exception('Expecting a numeric value for "interval"!')
39813983
if interval < 0:
@@ -4046,6 +4048,8 @@ def begin_presentation(
40464048
raise Exception('Presentation file must end in ".html"!')
40474049
if not interval:
40484050
interval = 0
4051+
if interval == 0 and self.interval:
4052+
interval = float(self.interval)
40494053
if not type(interval) is int and not type(interval) is float:
40504054
raise Exception('Expecting a numeric value for "interval"!')
40514055
if interval < 0:
@@ -4569,6 +4573,8 @@ def display_chart(self, chart_name=None, filename=None, interval=0):
45694573
filename = "my_chart.html"
45704574
if not interval:
45714575
interval = 0
4576+
if interval == 0 and self.interval:
4577+
interval = float(self.interval)
45724578
if not type(interval) is int and not type(interval) is float:
45734579
raise Exception('Expecting a numeric value for "interval"!')
45744580
if interval < 0:
@@ -5131,6 +5137,11 @@ def play_tour(self, name=None, interval=0):
51315137
if self.headless:
51325138
return # Tours should not run in headless mode.
51335139

5140+
if not interval:
5141+
interval = 0
5142+
if interval == 0 and self.interval:
5143+
interval = float(self.interval)
5144+
51345145
if not name:
51355146
name = "default"
51365147
if name not in self._tour_steps:
@@ -6670,6 +6681,7 @@ def setUp(self, masterqa_mode=False):
66706681
self.headless_active = False
66716682
self.headed = sb_config.headed
66726683
self.locale_code = sb_config.locale_code
6684+
self.interval = sb_config.interval
66736685
self.start_page = sb_config.start_page
66746686
self.log_path = sb_config.log_path
66756687
self.with_testing_base = sb_config.with_testing_base

seleniumbase/plugins/pytest_plugin.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def pytest_addoption(parser):
4545
--headless (Run tests headlessly. Default mode on Linux OS.)
4646
--headed (Run tests with a GUI on Linux OS.)
4747
--locale=LOCALE_CODE (Set the Language Locale Code for the web browser.)
48+
--interval=SECONDS (The autoplay interval for presentations & tour steps)
4849
--start-page=URL (The starting URL for the web browser when tests begin.)
4950
--archive-logs (Archive existing log files instead of deleting them.)
5051
--archive-downloads (Archive old downloads instead of deleting them.)
@@ -350,6 +351,15 @@ def pytest_addoption(parser):
350351
The Locale alters visible text on supported websites.
351352
See: https://seleniumbase.io/help_docs/locale_codes/
352353
Default: None. (The web browser's default mode.)""")
354+
parser.addoption('--interval',
355+
action='store',
356+
dest='interval',
357+
default=None,
358+
help="""This globally overrides the default interval,
359+
(in seconds), of features that include autoplay
360+
functionality, such as tours and presentations.
361+
Overrides from methods take priority over this.
362+
(Headless Mode skips tours and presentations.)""")
353363
parser.addoption('--start_page', '--start-page', '--url',
354364
action='store',
355365
dest='start_page',
@@ -658,6 +668,7 @@ def pytest_configure(config):
658668
sb_config.headless = config.getoption('headless')
659669
sb_config.headed = config.getoption('headed')
660670
sb_config.locale_code = config.getoption('locale_code')
671+
sb_config.interval = config.getoption('interval')
661672
sb_config.start_page = config.getoption('start_page')
662673
sb_config.extension_zip = config.getoption('extension_zip')
663674
sb_config.extension_dir = config.getoption('extension_dir')

seleniumbase/plugins/selenium_plugin.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class SeleniumBrowser(Plugin):
2626
--headless (Run tests headlessly. Default mode on Linux OS.)
2727
--headed (Run tests with a GUI on Linux OS.)
2828
--locale=LOCALE_CODE (Set the Language Locale Code for the web browser.)
29+
--interval=SECONDS (The autoplay interval for presentations & tour steps)
2930
--start-page=URL (The starting URL for the web browser when tests begin.)
3031
--time-limit=SECONDS (Safely fail any test that exceeds the time limit.)
3132
--slow (Slow down the automation. Faster than using Demo Mode.)
@@ -193,6 +194,16 @@ def options(self, parser, env):
193194
The Locale alters visible text on supported websites.
194195
See: https://seleniumbase.io/help_docs/locale_codes/
195196
Default: None. (The web browser's default mode.)""")
197+
parser.add_option(
198+
'--interval',
199+
action='store',
200+
dest='interval',
201+
default=None,
202+
help="""This globally overrides the default interval,
203+
(in seconds), of features that include autoplay
204+
functionality, such as tours and presentations.
205+
Overrides from methods take priority over this.
206+
(Headless Mode skips tours and presentations.)""")
196207
parser.add_option(
197208
'--start_page', '--start-page', '--url',
198209
action='store',
@@ -405,6 +416,7 @@ def beforeTest(self, test):
405416
test.test.headless = self.options.headless
406417
test.test.headed = self.options.headed
407418
test.test.locale_code = self.options.locale_code
419+
test.test.interval = self.options.interval
408420
test.test.start_page = self.options.start_page
409421
test.test.servername = self.options.servername
410422
test.test.port = self.options.port

0 commit comments

Comments
 (0)