Make --headless mode the default setting on Linux
This commit is contained in:
parent
1d1345ee80
commit
5ab75a3322
|
@ -3,6 +3,7 @@
|
|||
|
||||
import optparse
|
||||
import pytest
|
||||
import sys
|
||||
from seleniumbase import config as sb_config
|
||||
from seleniumbase.core import log_helper
|
||||
from seleniumbase.core import proxy_helper
|
||||
|
@ -296,7 +297,16 @@ def pytest_configure(config):
|
|||
sb_config.save_screenshot = config.getoption('save_screenshot')
|
||||
sb_config.visual_baseline = config.getoption('visual_baseline')
|
||||
sb_config.timeout_multiplier = config.getoption('timeout_multiplier')
|
||||
sb_config.pytest_html_report = config.getoption("htmlpath") # --html=FILE
|
||||
sb_config.pytest_html_report = config.getoption('htmlpath') # --html=FILE
|
||||
|
||||
if "linux" in sys.platform and (
|
||||
not sb_config.headed and not sb_config.headless):
|
||||
print(
|
||||
"(Running with --headless on Linux. "
|
||||
"Use --headed or --gui to override.)")
|
||||
sb_config.headless = True
|
||||
if not sb_config.headless:
|
||||
sb_config.headed = True
|
||||
|
||||
if sb_config.with_testing_base:
|
||||
log_helper.log_folder_setup(sb_config.log_path, sb_config.archive_logs)
|
||||
|
|
|
@ -3,8 +3,8 @@ This plugin gives the power of Selenium to nosetests
|
|||
by providing a WebDriver object for the tests to use.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from nose.plugins import Plugin
|
||||
from pyvirtualdisplay import Display
|
||||
from seleniumbase.core import proxy_helper
|
||||
from seleniumbase.fixtures import constants
|
||||
|
||||
|
@ -268,10 +268,26 @@ class SeleniumBrowser(Plugin):
|
|||
if test.test.servername != "localhost":
|
||||
# Use Selenium Grid (Use --server=127.0.0.1 for localhost Grid)
|
||||
test.test.use_grid = True
|
||||
if "linux" in sys.platform and (
|
||||
not self.options.headed and not self.options.headless):
|
||||
print(
|
||||
"(Running with --headless on Linux. "
|
||||
"Use --headed or --gui to override.)")
|
||||
self.options.headless = True
|
||||
test.test.headless = True
|
||||
if not self.options.headless:
|
||||
self.options.headed = True
|
||||
test.test.headed = True
|
||||
if self.options.headless:
|
||||
self.display = Display(visible=0, size=(1920, 1200))
|
||||
self.display.start()
|
||||
self.headless_active = True
|
||||
try:
|
||||
from pyvirtualdisplay import Display
|
||||
self.display = Display(visible=0, size=(1440, 1080))
|
||||
self.display.start()
|
||||
self.headless_active = True
|
||||
except Exception:
|
||||
# pyvirtualdisplay might not be necessary anymore because
|
||||
# Chrome and Firefox now have built-in headless displays
|
||||
pass
|
||||
# The driver will be received later
|
||||
self.driver = None
|
||||
test.test.driver = self.driver
|
||||
|
|
Loading…
Reference in New Issue