Skip to content

Commit e08e27a

Browse files
committed
Add --headed parameter to override Linux headless mode
1 parent c5f58c0 commit e08e27a

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3170,6 +3170,7 @@ def setUp(self, masterqa_mode=False):
31703170
self.with_selenium = sb_config.with_selenium # Should be True
31713171
self.headless = sb_config.headless
31723172
self.headless_active = False
3173+
self.headed = sb_config.headed
31733174
self.log_path = sb_config.log_path
31743175
self.with_testing_base = sb_config.with_testing_base
31753176
self.with_basic_test_info = sb_config.with_basic_test_info

seleniumbase/plugins/pytest_plugin.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,18 @@ def pytest_addoption(parser):
159159
action="store_true",
160160
dest='headless',
161161
default=False,
162-
help="""Using this makes Webdriver run headlessly,
163-
which is required on headless machines.""")
162+
help="""Using this makes Webdriver run web browsers
163+
headlessly, which is required on headless machines.
164+
Default: False on Mac/Windows. True on Linux.""")
165+
parser.addoption('--headed', '--gui',
166+
action="store_true",
167+
dest='headed',
168+
default=False,
169+
help="""Using this makes Webdriver run web browsers with
170+
a GUI when running tests on Linux machines.
171+
(The default setting on Linux is headless.)
172+
(The default setting on Mac or Windows is headed.)
173+
""")
164174
parser.addoption('--is_pytest', '--is-pytest',
165175
action="store_true",
166176
dest='is_pytest',
@@ -257,6 +267,7 @@ def pytest_configure(config):
257267
sb_config.with_selenium = config.getoption('with_selenium')
258268
sb_config.user_agent = config.getoption('user_agent')
259269
sb_config.headless = config.getoption('headless')
270+
sb_config.headed = config.getoption('headed')
260271
sb_config.extension_zip = config.getoption('extension_zip')
261272
sb_config.extension_dir = config.getoption('extension_dir')
262273
sb_config.with_testing_base = config.getoption('with_testing_base')

seleniumbase/plugins/selenium_plugin.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class SeleniumBrowser(Plugin):
2525
self.options.extension_zip -- load a Chrome Extension ZIP (--extension_zip)
2626
self.options.extension_dir -- load a Chrome Extension DIR (--extension_dir)
2727
self.options.headless -- the option to run headlessly (--headless)
28+
self.options.headed -- the option to run with a GUI on Linux (--headed)
2829
self.options.demo_mode -- the option to slow down Selenium (--demo_mode)
2930
self.options.demo_sleep -- Selenium action delay in DemoMode (--demo_sleep)
3031
self.options.highlights -- # of highlight animations shown (--highlights)
@@ -128,8 +129,18 @@ def options(self, parser, env):
128129
action="store_true",
129130
dest='headless',
130131
default=False,
131-
help="""Using this makes Webdriver run headlessly,
132-
which is required on headless machines.""")
132+
help="""Using this makes Webdriver run web browsers headlessly,
133+
which is required on headless machines.
134+
Default: False on Mac/Windows. True on Linux.""")
135+
parser.add_option(
136+
'--headed', '--gui',
137+
action="store_true",
138+
dest='headed',
139+
default=False,
140+
help="""Using this makes Webdriver run web browsers with
141+
a GUI when running tests on Linux machines.
142+
(The default setting on Linux is headless.)
143+
(The default setting on Mac or Windows is headed.)""")
133144
parser.add_option(
134145
'--demo_mode', '--demo-mode', '--demo',
135146
action="store_true",
@@ -233,6 +244,7 @@ def beforeTest(self, test):
233244
test.test.browser = self.options.browser
234245
test.test.cap_file = self.options.cap_file
235246
test.test.headless = self.options.headless
247+
test.test.headed = self.options.headed
236248
test.test.servername = self.options.servername
237249
test.test.port = self.options.port
238250
test.test.user_data_dir = self.options.user_data_dir

0 commit comments

Comments
 (0)