Skip to content

Headless mode updates #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ pytest my_first_test.py --demo_mode

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/)

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.

### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Install/upgrade ``pip``:

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

### <img src="https://cdn2.hubspot.net/hubfs/100006/images/super_square_logo_3a.png" title="SeleniumBase" height="32"> Setup a Virtual Environment (optional):

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.

### <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)
```
pip install seleniumbase
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ urllib3==1.25.3
requests>=2.22.0
selenium==3.141.0
pluggy>=0.12.0
pytest>=4.6.2
pytest>=4.6.3
pytest-cov>=2.7.1
pytest-forked>=1.0.2
pytest-html>=1.20.0
pytest-html>=1.21.0
pytest-metadata>=1.8.0
pytest-ordering>=0.6
pytest-rerunfailures>=7.0
pytest-xdist>=1.28.0
pytest-xdist>=1.29.0
parameterized>=0.7.0
beautifulsoup4>=4.6.0
pyopenssl>=19.0.0
Expand Down
34 changes: 14 additions & 20 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def _set_chrome_options(
}
}
chrome_options.add_experimental_option("prefs", prefs)
if headless:
chrome_options.add_experimental_option("w3c", False)
chrome_options.add_argument("--test-type")
chrome_options.add_argument("--log-level=3")
chrome_options.add_argument("--no-first-run")
Expand All @@ -129,6 +131,18 @@ def _set_chrome_options(
chrome_options = _add_chrome_proxy_extension(
chrome_options, proxy_string, proxy_user, proxy_pass)
chrome_options.add_argument('--proxy-server=%s' % proxy_string)
if headless:
if not proxy_auth:
# Headless Chrome doesn't support extensions, which are
# required when using a proxy server that has authentication.
# Instead, base_case.py will use PyVirtualDisplay when not
# using Chrome's built-in headless mode. See link for details:
# https://bugs.chromium.org/p/chromium/issues/detail?id=706008
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument("--disable-setuid-sandbox")
chrome_options.add_argument("--disable-dev-shm-usage")
return chrome_options


Expand Down Expand Up @@ -280,16 +294,6 @@ def get_remote_driver(
chrome_options = _set_chrome_options(
downloads_path, headless, proxy_string, proxy_auth,
proxy_user, proxy_pass, user_agent, disable_csp)
if headless:
if not proxy_auth:
# Headless Chrome doesn't support extensions, which are
# required when using a proxy server that has authentication.
# Instead, base_case.py will use PyVirtualDisplay when not
# using Chrome's built-in headless mode. See link for details:
# https://bugs.chromium.org/p/chromium/issues/detail?id=706008
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--no-sandbox")
capabilities = chrome_options.to_capabilities()
for key in desired_caps.keys():
capabilities[key] = desired_caps[key]
Expand Down Expand Up @@ -491,16 +495,6 @@ def get_local_driver(
chrome_options = _set_chrome_options(
downloads_path, headless, proxy_string, proxy_auth,
proxy_user, proxy_pass, user_agent, disable_csp)
if headless:
# Headless Chrome doesn't support extensions, which are
# required when using a proxy server that has authentication.
# Instead, base_case.py will use PyVirtualDisplay when not
# using Chrome's built-in headless mode. See link for details:
# https://bugs.chromium.org/p/chromium/issues/detail?id=706008
if not proxy_auth:
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--no-sandbox")
if LOCAL_CHROMEDRIVER and os.path.exists(LOCAL_CHROMEDRIVER):
make_driver_executable_if_not(LOCAL_CHROMEDRIVER)
return webdriver.Chrome(
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setup(
name='seleniumbase',
version='1.23.13',
version='1.23.14',
description='Reliable Browser Automation & Testing Framework',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down Expand Up @@ -63,14 +63,14 @@
'requests>=2.22.0',
'selenium==3.141.0',
'pluggy>=0.12.0',
'pytest>=4.6.2',
'pytest>=4.6.3',
'pytest-cov>=2.7.1',
'pytest-forked>=1.0.2',
'pytest-html>=1.20.0',
'pytest-html>=1.21.0',
'pytest-metadata>=1.8.0',
'pytest-ordering>=0.6',
'pytest-rerunfailures>=7.0',
'pytest-xdist>=1.28.0',
'pytest-xdist>=1.29.0',
'parameterized>=0.7.0',
'beautifulsoup4>=4.6.0', # Keep at >=4.6.0 while using "bs4"
'pyopenssl>=19.0.0',
Expand Down