Skip to content

Commit e1cebd0

Browse files
authored
Merge pull request #332 from seleniumbase/headless-mode-updates
Headless mode updates
2 parents 2915b60 + b4c1289 commit e1cebd0

File tree

4 files changed

+25
-29
lines changed

4 files changed

+25
-29
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ pytest my_first_test.py --demo_mode
1414

1515
You'll need **[Python](https://www.python.org/downloads/)** [<img src="https://img.shields.io/badge/python-2.7,_3.5,_3.6,_3.7-22AADD.svg" alt="Python versions" />](https://www.python.org/downloads/)
1616

17-
Optionally, you may want a [Python virtual environment](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md) to isolate Python dependencies between projects.
18-
1917
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Install/upgrade ``pip``:
2018

2119
With Python installed and on your System PATH, you can get the latest ``pip`` with:
2220
```
2321
python -m easy_install -U pip
2422
```
2523

24+
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Setup a Virtual Environment (optional):
25+
26+
Optionally, you may want to use a **[Python Virtual Environment](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md)** to isolate Python dependencies between projects.
27+
2628
### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Install ``seleniumbase``: [<img src="https://img.shields.io/badge/pypi-seleniumbase-22AAEE.svg" alt="pypi" />](https://pypi.python.org/pypi/seleniumbase)
2729
```
2830
pip install seleniumbase

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ urllib3==1.25.3
1010
requests>=2.22.0
1111
selenium==3.141.0
1212
pluggy>=0.12.0
13-
pytest>=4.6.2
13+
pytest>=4.6.3
1414
pytest-cov>=2.7.1
1515
pytest-forked>=1.0.2
16-
pytest-html>=1.20.0
16+
pytest-html>=1.21.0
1717
pytest-metadata>=1.8.0
1818
pytest-ordering>=0.6
1919
pytest-rerunfailures>=7.0
20-
pytest-xdist>=1.28.0
20+
pytest-xdist>=1.29.0
2121
parameterized>=0.7.0
2222
beautifulsoup4>=4.6.0
2323
pyopenssl>=19.0.0

seleniumbase/core/browser_launcher.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ def _set_chrome_options(
106106
}
107107
}
108108
chrome_options.add_experimental_option("prefs", prefs)
109+
if headless:
110+
chrome_options.add_experimental_option("w3c", False)
109111
chrome_options.add_argument("--test-type")
110112
chrome_options.add_argument("--log-level=3")
111113
chrome_options.add_argument("--no-first-run")
@@ -129,6 +131,18 @@ def _set_chrome_options(
129131
chrome_options = _add_chrome_proxy_extension(
130132
chrome_options, proxy_string, proxy_user, proxy_pass)
131133
chrome_options.add_argument('--proxy-server=%s' % proxy_string)
134+
if headless:
135+
if not proxy_auth:
136+
# Headless Chrome doesn't support extensions, which are
137+
# required when using a proxy server that has authentication.
138+
# Instead, base_case.py will use PyVirtualDisplay when not
139+
# using Chrome's built-in headless mode. See link for details:
140+
# https://bugs.chromium.org/p/chromium/issues/detail?id=706008
141+
chrome_options.add_argument("--headless")
142+
chrome_options.add_argument("--disable-gpu")
143+
chrome_options.add_argument("--no-sandbox")
144+
chrome_options.add_argument("--disable-setuid-sandbox")
145+
chrome_options.add_argument("--disable-dev-shm-usage")
132146
return chrome_options
133147

134148

@@ -280,16 +294,6 @@ def get_remote_driver(
280294
chrome_options = _set_chrome_options(
281295
downloads_path, headless, proxy_string, proxy_auth,
282296
proxy_user, proxy_pass, user_agent, disable_csp)
283-
if headless:
284-
if not proxy_auth:
285-
# Headless Chrome doesn't support extensions, which are
286-
# required when using a proxy server that has authentication.
287-
# Instead, base_case.py will use PyVirtualDisplay when not
288-
# using Chrome's built-in headless mode. See link for details:
289-
# https://bugs.chromium.org/p/chromium/issues/detail?id=706008
290-
chrome_options.add_argument("--headless")
291-
chrome_options.add_argument("--disable-gpu")
292-
chrome_options.add_argument("--no-sandbox")
293297
capabilities = chrome_options.to_capabilities()
294298
for key in desired_caps.keys():
295299
capabilities[key] = desired_caps[key]
@@ -491,16 +495,6 @@ def get_local_driver(
491495
chrome_options = _set_chrome_options(
492496
downloads_path, headless, proxy_string, proxy_auth,
493497
proxy_user, proxy_pass, user_agent, disable_csp)
494-
if headless:
495-
# Headless Chrome doesn't support extensions, which are
496-
# required when using a proxy server that has authentication.
497-
# Instead, base_case.py will use PyVirtualDisplay when not
498-
# using Chrome's built-in headless mode. See link for details:
499-
# https://bugs.chromium.org/p/chromium/issues/detail?id=706008
500-
if not proxy_auth:
501-
chrome_options.add_argument("--headless")
502-
chrome_options.add_argument("--disable-gpu")
503-
chrome_options.add_argument("--no-sandbox")
504498
if LOCAL_CHROMEDRIVER and os.path.exists(LOCAL_CHROMEDRIVER):
505499
make_driver_executable_if_not(LOCAL_CHROMEDRIVER)
506500
return webdriver.Chrome(

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name='seleniumbase',
20-
version='1.23.13',
20+
version='1.23.14',
2121
description='Reliable Browser Automation & Testing Framework',
2222
long_description=long_description,
2323
long_description_content_type='text/markdown',
@@ -63,14 +63,14 @@
6363
'requests>=2.22.0',
6464
'selenium==3.141.0',
6565
'pluggy>=0.12.0',
66-
'pytest>=4.6.2',
66+
'pytest>=4.6.3',
6767
'pytest-cov>=2.7.1',
6868
'pytest-forked>=1.0.2',
69-
'pytest-html>=1.20.0',
69+
'pytest-html>=1.21.0',
7070
'pytest-metadata>=1.8.0',
7171
'pytest-ordering>=0.6',
7272
'pytest-rerunfailures>=7.0',
73-
'pytest-xdist>=1.28.0',
73+
'pytest-xdist>=1.29.0',
7474
'parameterized>=0.7.0',
7575
'beautifulsoup4>=4.6.0', # Keep at >=4.6.0 while using "bs4"
7676
'pyopenssl>=19.0.0',

0 commit comments

Comments
 (0)