recent selenium does not support headless property

This commit is contained in:
unknown 2025-04-22 19:34:41 +09:00
parent e7430aaeec
commit 5ebdc22d19

View File

@ -4305,14 +4305,13 @@ class WebDriverJSWrapper(object):
if not check_executable('geckodriver', ['--version']): if not check_executable('geckodriver', ['--version']):
self._raise_exception('geckodriver not found in PATH') self._raise_exception('geckodriver not found in PATH')
o = wd.FirefoxOptions() o = wd.FirefoxOptions()
o.headless = True o.add_argument('-headless')
s = wd.firefox.service.Service(log_path=os.path.devnull) self._webdriver = wd.Firefox(options=o)
self._webdriver = wd.Firefox(options=o, service=s)
elif webdriver_type == 'chrome': # chromedriver elif webdriver_type == 'chrome': # chromedriver
if not check_executable('chromedriver', ['--version']): if not check_executable('chromedriver', ['--version']):
self._raise_exception('chromedriver not found in PATH') self._raise_exception('chromedriver not found in PATH')
o = wd.ChromeOptions() o = wd.ChromeOptions()
o.headless = True o.add_argument('--headless')
""" """
If you are using the snap version of the chromium, chromedriver is included in the snap package. If you are using the snap version of the chromium, chromedriver is included in the snap package.
You should use that driver. You should use that driver.
@ -4326,7 +4325,7 @@ class WebDriverJSWrapper(object):
if not check_executable('msedgedriver', ['--version']): if not check_executable('msedgedriver', ['--version']):
self._raise_exception('msedgedriver not found in PATH') self._raise_exception('msedgedriver not found in PATH')
o = wd.EdgeOptions() o = wd.EdgeOptions()
o.headless = True o.add_argument('--headless')
self._webdriver = wd.Edge(options=o) self._webdriver = wd.Edge(options=o)
elif webdriver_type == 'safari': # safaridriver elif webdriver_type == 'safari': # safaridriver
if not check_executable('safaridriver', ['--version']): if not check_executable('safaridriver', ['--version']):