Skip to content

Update browser options #359

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 6 commits into from
Aug 14, 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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/sb_media_logo_4.png" title="SeleniumBase" height="163">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/sb_media_logo_bold.png" title="SeleniumBase" height="165">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)

[<img src="https://img.shields.io/github/release/seleniumbase/SeleniumBase.svg" />](https://github.com/seleniumbase/SeleniumBase/releases) [<img src="https://dev.azure.com/seleniumbase/seleniumbase/_apis/build/status/seleniumbase.SeleniumBase?branchName=master" />](https://dev.azure.com/seleniumbase/seleniumbase/_build/latest?definitionId=1&branchName=master) [<img src="https://travis-ci.org/seleniumbase/SeleniumBase.svg?branch=master" alt="Build Status" />](https://travis-ci.org/seleniumbase/SeleniumBase) [<img src="https://badges.gitter.im/seleniumbase/SeleniumBase.svg" alt="Join the SeleniumBase Gitter chat" />](https://gitter.im/seleniumbase/SeleniumBase) [<img src="https://img.shields.io/badge/license-MIT-22BBCC.svg" alt="MIT License" />](https://github.com/seleniumbase/SeleniumBase/blob/master/LICENSE) [<img src="https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg" alt="Stars" />](https://github.com/seleniumbase/SeleniumBase/stargazers) [<img src="https://img.shields.io/github/repo-size/seleniumbase/seleniumbase.svg" alt="Size" />](https://github.com/seleniumbase/SeleniumBase/releases)<br />

✅ Everything you need to automate Web/UI testing.
✅ Everything you need for automating Web/UI testing.

<img src="https://cdn2.hubspot.net/hubfs/100006/images/new_demo_gif.gif" title="SeleniumBase" height="224"><br />
<img src="https://cdn2.hubspot.net/hubfs/100006/images/new_demo_gif.gif" title="SeleniumBase" height="225"><br />
(<i>Above: [my_first_test.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) from [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) running in demo mode, which adds JavaScript for highlighting page actions.</i>)<br />
```
pytest my_first_test.py --demo_mode
Expand All @@ -25,7 +25,7 @@ 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)

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. (The official virtualenv tutorial can be found **[here](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)**.)
You may want to use a **Python Virtual Environment** to isolate Python dependencies between projects. (The Seleniumbase virtualenv tutorial can be found **[here](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md)**, and the official virtualenv tutorial can be found **[here](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/)**.)

### <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)
```
Expand Down
2 changes: 2 additions & 0 deletions examples/raw_parameter_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
b.disable_csp = False
b.enable_sync = False
b.visual_baseline = False
b.maximize_window = False
b.save_screenshot_after_test = False
b.timeout_multiplier = None
b.pytest_html_report = None
Expand All @@ -54,6 +55,7 @@
b.demo_mode = False
b.demo_sleep = 1
b.message_duration = 2
b.settings_file = None
b.user_data_dir = None
b.proxy_string = None
b.ad_block_on = False
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip>=19.2.2
setuptools>=41.0.1
setuptools>=41.1.0
wheel>=0.33.4
six
nose
Expand Down
8 changes: 6 additions & 2 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def _set_chrome_options(
}
chrome_options.add_experimental_option("prefs", prefs)
chrome_options.add_experimental_option("w3c", True)
chrome_options.add_experimental_option(
"excludeSwitches", ["enable-automation"])
chrome_options.add_experimental_option("useAutomationExtension", False)
if enable_sync:
chrome_options.add_experimental_option(
"excludeSwitches", ["disable-sync"])
Expand Down Expand Up @@ -159,9 +162,10 @@ def _set_chrome_options(
# 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")
if "linux" in PLATFORM:
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("--no-sandbox")
if "linux" in PLATFORM:
chrome_options.add_argument("--disable-dev-shm-usage")
return chrome_options


Expand Down
6 changes: 5 additions & 1 deletion seleniumbase/fixtures/base_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -2778,7 +2778,10 @@ def get_new_driver(self, browser=None, headless=None,
else:
if self.browser == 'chrome' or self.browser == 'opera':
try:
self.driver.set_window_size(1250, 840)
if self.maximize_window:
self.driver.maximize_window()
else:
self.driver.set_window_size(1250, 840)
self.wait_for_ready_state_complete()
except Exception:
pass # Keep existing browser resolution
Expand Down Expand Up @@ -3207,6 +3210,7 @@ def setUp(self, masterqa_mode=False):
self.user_data_dir = sb_config.user_data_dir
self.extension_zip = sb_config.extension_zip
self.extension_dir = sb_config.extension_dir
self.maximize_window = sb_config.maximize_window
self.save_screenshot_after_test = sb_config.save_screenshot
self.visual_baseline = sb_config.visual_baseline
self.timeout_multiplier = sb_config.timeout_multiplier
Expand Down
9 changes: 9 additions & 0 deletions seleniumbase/plugins/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def pytest_addoption(parser):
--verify_delay=SECONDS (The delay before MasterQA verification checks.)
--disable_csp (This disables the Content Security Policy of websites.)
--enable_sync (The option to enable "Chrome Sync".)
--maximize_window (The option to start with the web browser maximized.)
--save_screenshot (The option to save a screenshot after each test.)
--visual_baseline (Set the visual baseline for Visual/Layout tests.)
--timeout_multiplier=MULTIPLIER (Multiplies the default timeout values.)
Expand Down Expand Up @@ -281,6 +282,13 @@ def pytest_addoption(parser):
dest='enable_sync',
default=False,
help="""Using this enables the "Chrome Sync" feature.""")
parser.addoption('--maximize_window', '--maximize-window', '--maximize',
'--fullscreen',
action="store_true",
dest='maximize_window',
default=False,
help="""The option to start with the browser window
maximized.""")
parser.addoption('--save_screenshot', '--save-screenshot',
action='store_true',
dest='save_screenshot',
Expand Down Expand Up @@ -341,6 +349,7 @@ def pytest_configure(config):
sb_config.verify_delay = config.getoption('verify_delay')
sb_config.disable_csp = config.getoption('disable_csp')
sb_config.enable_sync = config.getoption('enable_sync')
sb_config.maximize_window = config.getoption('maximize_window')
sb_config.save_screenshot = config.getoption('save_screenshot')
sb_config.visual_baseline = config.getoption('visual_baseline')
sb_config.timeout_multiplier = config.getoption('timeout_multiplier')
Expand Down
9 changes: 9 additions & 0 deletions seleniumbase/plugins/selenium_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class SeleniumBrowser(Plugin):
--verify_delay=SECONDS (The delay before MasterQA verification checks.)
--disable_csp (This disables the Content Security Policy of websites.)
--enable_sync (The option to enable "Chrome Sync".)
--maximize_window (The option to start with the web browser maximized.)
--save_screenshot (The option to save a screenshot after each test.)
--visual_baseline (Set the visual baseline for Visual/Layout tests.)
--timeout_multiplier=MULTIPLIER (Multiplies the default timeout values.)
Expand Down Expand Up @@ -212,6 +213,13 @@ def options(self, parser, env):
dest='enable_sync',
default=False,
help="""Using this enables the "Chrome Sync" feature.""")
parser.add_option(
'--maximize_window', '--maximize-window', '--maximize',
'--fullscreen',
action="store_true",
dest='maximize_window',
default=False,
help="""The option to start with the web browser maximized.""")
parser.add_option(
'--save_screenshot', '--save-screenshot',
action="store_true",
Expand Down Expand Up @@ -266,6 +274,7 @@ def beforeTest(self, test):
test.test.verify_delay = self.options.verify_delay # MasterQA
test.test.disable_csp = self.options.disable_csp
test.test.enable_sync = self.options.enable_sync
test.test.maximize_window = self.options.maximize_window
test.test.save_screenshot_after_test = self.options.save_screenshot
test.test.visual_baseline = self.options.visual_baseline
test.test.timeout_multiplier = self.options.timeout_multiplier
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setup(
name='seleniumbase',
version='1.28.3',
version='1.29.0',
description='Fast, Easy, and Reliable Browser Automation & Testing.',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down