|
3 | 3 | by providing a WebDriver object for the tests to use.
|
4 | 4 | """
|
5 | 5 |
|
| 6 | +import sys |
6 | 7 | from nose.plugins import Plugin
|
7 |
| -from pyvirtualdisplay import Display |
8 | 8 | from seleniumbase.core import proxy_helper
|
9 | 9 | from seleniumbase.fixtures import constants
|
10 | 10 |
|
@@ -268,10 +268,26 @@ def beforeTest(self, test):
|
268 | 268 | if test.test.servername != "localhost":
|
269 | 269 | # Use Selenium Grid (Use --server=127.0.0.1 for localhost Grid)
|
270 | 270 | test.test.use_grid = True
|
| 271 | + if "linux" in sys.platform and ( |
| 272 | + not self.options.headed and not self.options.headless): |
| 273 | + print( |
| 274 | + "(Running with --headless on Linux. " |
| 275 | + "Use --headed or --gui to override.)") |
| 276 | + self.options.headless = True |
| 277 | + test.test.headless = True |
| 278 | + if not self.options.headless: |
| 279 | + self.options.headed = True |
| 280 | + test.test.headed = True |
271 | 281 | if self.options.headless:
|
272 |
| - self.display = Display(visible=0, size=(1920, 1200)) |
273 |
| - self.display.start() |
274 |
| - self.headless_active = True |
| 282 | + try: |
| 283 | + from pyvirtualdisplay import Display |
| 284 | + self.display = Display(visible=0, size=(1440, 1080)) |
| 285 | + self.display.start() |
| 286 | + self.headless_active = True |
| 287 | + except Exception: |
| 288 | + # pyvirtualdisplay might not be necessary anymore because |
| 289 | + # Chrome and Firefox now have built-in headless displays |
| 290 | + pass |
275 | 291 | # The driver will be received later
|
276 | 292 | self.driver = None
|
277 | 293 | test.test.driver = self.driver
|
|
0 commit comments