Skip to content

Commit 8ab15e0

Browse files
authored
Merge pull request #135 from seleniumbase/upgrade-headless-mode
Upgrade headless mode
2 parents d7e94d9 + a1605d4 commit 8ab15e0

File tree

8 files changed

+24
-15
lines changed

8 files changed

+24
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ nosetests.xml
2828

2929
# py.test
3030
.cache/*
31+
.pytest_cache/*
3132
.pytest_config
3233

3334
# Developer

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ setuptools>=38.2.4
33
ipython==5.4.1
44
selenium==3.8.0
55
nose==1.3.7
6-
pytest==3.2.5
7-
pytest-html==1.16.0
6+
pytest==3.4.0
7+
pytest-html==1.16.1
88
six==1.10.0
99
flake8==3.4.1
1010
requests==2.18.4

seleniumbase/core/browser_launcher.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _create_firefox_profile(downloads_path):
2929
return profile
3030

3131

32-
def get_driver(browser_name):
32+
def get_driver(browser_name, headless=False):
3333
'''
3434
Spins up a new web browser and returns the driver.
3535
Tests that run with pytest spin up the browser from here.
@@ -45,8 +45,12 @@ def get_driver(browser_name):
4545
profile = _create_firefox_profile(downloads_path)
4646
firefox_capabilities = DesiredCapabilities.FIREFOX.copy()
4747
firefox_capabilities['marionette'] = True
48+
options = webdriver.FirefoxOptions()
49+
if headless:
50+
options.add_argument('-headless')
4851
firefox_driver = webdriver.Firefox(
49-
firefox_profile=profile, capabilities=firefox_capabilities)
52+
firefox_profile=profile, capabilities=firefox_capabilities,
53+
firefox_options=options)
5054
except WebDriverException:
5155
# Don't use Geckodriver: Only works for old versions of Firefox
5256
profile = _create_firefox_profile(downloads_path)
@@ -79,6 +83,8 @@ def get_driver(browser_name):
7983
chrome_options.add_argument("--allow-file-access-from-files")
8084
chrome_options.add_argument("--allow-running-insecure-content")
8185
chrome_options.add_argument("--disable-infobars")
86+
if headless:
87+
chrome_options.add_argument("--headless")
8288
if settings.START_CHROME_IN_FULL_SCREEN_MODE:
8389
# Run Chrome in full screen mode on WINDOWS
8490
chrome_options.add_argument("--start-maximized")

seleniumbase/fixtures/base_case.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,8 @@ def setUp(self):
14201420
self.display.start()
14211421
self.headless_active = True
14221422
if self.with_selenium:
1423-
self.driver = browser_launcher.get_driver(self.browser)
1423+
self.driver = browser_launcher.get_driver(self.browser,
1424+
self.headless)
14241425

14251426
def __insert_test_result(self, state, err):
14261427
data_payload = TestcaseDataPayload()

seleniumbase/plugins/selenium_plugin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def beforeTest(self, test):
134134
from how Selenium is run remotely, such as from Jenkins. """
135135

136136
if self.options.headless:
137-
self.display = Display(visible=0, size=(1200, 800))
137+
self.display = Display(visible=0, size=(1920, 1200))
138138
self.display.start()
139139
self.headless_active = True
140140
if self.options.servername == "localhost":
@@ -201,4 +201,5 @@ def __select_browser(self, browser_name):
201201
self.options.port),
202202
self.browser_settings)
203203
else:
204-
return browser_launcher.get_driver(browser_name)
204+
return browser_launcher.get_driver(browser_name,
205+
self.options.headless)

server_requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ setuptools>=38.2.4
33
ipython==5.4.1
44
selenium==2.53.6
55
nose==1.3.7
6-
pytest==3.2.5
7-
pytest-html==1.16.0
6+
pytest==3.4.0
7+
pytest-html==1.16.1
88
six==1.10.0
99
flake8==3.4.1
1010
requests==2.18.4

server_setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='seleniumbase',
11-
version='1.4.16',
11+
version='1.4.17',
1212
description='Web Automation & Testing Framework - http://seleniumbase.com',
1313
long_description='Web Automation and Testing Framework - seleniumbase.com',
1414
platforms='Mac * Windows * Linux * Docker',
@@ -23,8 +23,8 @@
2323
'ipython==5.4.1',
2424
'selenium==2.53.6',
2525
'nose==1.3.7',
26-
'pytest==3.2.5',
27-
'pytest-html==1.16.0',
26+
'pytest==3.4.0',
27+
'pytest-html==1.16.1',
2828
'six==1.10.0',
2929
'flake8==3.4.1',
3030
'requests==2.18.4',

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name='seleniumbase',
11-
version='1.4.16',
11+
version='1.4.17',
1212
description='Web Automation & Testing Framework - http://seleniumbase.com',
1313
long_description='Web Automation and Testing Framework - seleniumbase.com',
1414
platforms='Mac * Windows * Linux * Docker',
@@ -23,8 +23,8 @@
2323
'ipython==5.4.1',
2424
'selenium==3.8.0',
2525
'nose==1.3.7',
26-
'pytest==3.2.5',
27-
'pytest-html==1.16.0',
26+
'pytest==3.4.0',
27+
'pytest-html==1.16.1',
2828
'six==1.10.0',
2929
'flake8==3.4.1',
3030
'requests==2.18.4',

0 commit comments

Comments
 (0)