Skip to content

Commit 4ed760c

Browse files
committed
Add more custom parameters for passing into tests
1 parent 9ec5b44 commit 4ed760c

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4509,6 +4509,9 @@ def setUp(self, masterqa_mode=False):
45094509
test_id = self.__get_test_id()
45104510
self.browser = sb_config.browser
45114511
self.data = sb_config.data
4512+
self.var1 = sb_config.var1
4513+
self.var2 = sb_config.var2
4514+
self.var3 = sb_config.var3
45124515
self.slow_mode = sb_config.slow_mode
45134516
self.demo_mode = sb_config.demo_mode
45144517
self.demo_sleep = sb_config.demo_sleep

seleniumbase/plugins/base_plugin.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class Base(Plugin):
1515
This parser plugin includes the following command-line options for Nose:
1616
--env=ENV (Set a test environment. Use "self.env" to use this in tests.)
1717
--data=DATA (Extra data to pass to tests. Use "self.data" in tests.)
18+
--var1=DATA (Extra data to pass to tests. Use "self.var1" in tests.)
19+
--var2=DATA (Extra data to pass to tests. Use "self.var2" in tests.)
20+
--var3=DATA (Extra data to pass to tests. Use "self.var3" in tests.)
1821
--settings-file=FILE (Overrides SeleniumBase settings.py values.)
1922
--archive-logs (Archive old log files instead of deleting them.)
2023
--report (The option to create a fancy report after tests complete.)
@@ -45,7 +48,22 @@ def options(self, parser, env):
4548
'--data',
4649
dest='data',
4750
default=None,
48-
help='Extra data to pass from the command line.')
51+
help='Extra data to pass to tests from the command line.')
52+
parser.add_option(
53+
'--var1',
54+
dest='var1',
55+
default=None,
56+
help='Extra data to pass to tests from the command line.')
57+
parser.add_option(
58+
'--var2',
59+
dest='var2',
60+
default=None,
61+
help='Extra data to pass to tests from the command line.')
62+
parser.add_option(
63+
'--var3',
64+
dest='var3',
65+
default=None,
66+
help='Extra data to pass to tests from the command line.')
4967
parser.add_option(
5068
'--settings_file', '--settings-file', '--settings',
5169
action='store',
@@ -123,6 +141,9 @@ def beforeTest(self, test):
123141
test.test.environment = self.options.environment
124142
test.test.env = self.options.environment # Add a shortened version
125143
test.test.data = self.options.data
144+
test.test.var1 = self.options.var1
145+
test.test.var2 = self.options.var2
146+
test.test.var3 = self.options.var3
126147
test.test.settings_file = self.options.settings_file
127148
test.test.log_path = self.options.log_path
128149
test.test.args = self.options

seleniumbase/plugins/pytest_plugin.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ def pytest_addoption(parser):
1818
--settings-file=FILE (Overrides SeleniumBase settings.py values.)
1919
--env=ENV (Set a test environment. Use "self.env" to use this in tests.)
2020
--data=DATA (Extra data to pass to tests. Use "self.data" in tests.)
21+
--var1=DATA (Extra data to pass to tests. Use "self.var1" in tests.)
22+
--var2=DATA (Extra data to pass to tests. Use "self.var2" in tests.)
23+
--var3=DATA (Extra data to pass to tests. Use "self.var3" in tests.)
2124
--user-data-dir=DIR (Set the Chrome user data directory to use.)
2225
--server=SERVER (The server / IP address used by the tests.)
2326
--port=PORT (The port that's used by the test server.)
@@ -87,7 +90,19 @@ def pytest_addoption(parser):
8790
parser.addoption('--data',
8891
dest='data',
8992
default=None,
90-
help='Extra data to pass from the command line.')
93+
help='Extra data to pass to tests from the command line.')
94+
parser.addoption('--var1',
95+
dest='var1',
96+
default=None,
97+
help='Extra data to pass to tests from the command line.')
98+
parser.addoption('--var2',
99+
dest='var2',
100+
default=None,
101+
help='Extra data to pass to tests from the command line.')
102+
parser.addoption('--var3',
103+
dest='var3',
104+
default=None,
105+
help='Extra data to pass to tests from the command line.')
91106
parser.addoption('--cap_file', '--cap-file',
92107
dest='cap_file',
93108
default=None,
@@ -407,6 +422,9 @@ def pytest_configure(config):
407422
sb_config.is_pytest = True
408423
sb_config.browser = config.getoption('browser')
409424
sb_config.data = config.getoption('data')
425+
sb_config.var1 = config.getoption('var1')
426+
sb_config.var2 = config.getoption('var2')
427+
sb_config.var3 = config.getoption('var3')
410428
sb_config.environment = config.getoption('environment')
411429
sb_config.with_selenium = config.getoption('with_selenium')
412430
sb_config.user_agent = config.getoption('user_agent')

0 commit comments

Comments
 (0)