Skip to content

Commit 181bef9

Browse files
authored
Merge pull request #359 from seleniumbase/browser-options
Update browser options
2 parents b1e31a2 + d9b968f commit 181bef9

File tree

8 files changed

+37
-9
lines changed

8 files changed

+37
-9
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
[<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)
1+
[<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)
22

33
[<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 />
44

5-
✅ Everything you need to automate Web/UI testing.
5+
✅ Everything you need for automating Web/UI testing.
66

7-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/new_demo_gif.gif" title="SeleniumBase" height="224"><br />
7+
<img src="https://cdn2.hubspot.net/hubfs/100006/images/new_demo_gif.gif" title="SeleniumBase" height="225"><br />
88
(<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 />
99
```
1010
pytest my_first_test.py --demo_mode
@@ -25,7 +25,7 @@ python -m easy_install -U pip
2525

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

28-
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/)**.)
28+
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/)**.)
2929

3030
### <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)
3131
```

examples/raw_parameter_script.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
b.disable_csp = False
4444
b.enable_sync = False
4545
b.visual_baseline = False
46+
b.maximize_window = False
4647
b.save_screenshot_after_test = False
4748
b.timeout_multiplier = None
4849
b.pytest_html_report = None
@@ -54,6 +55,7 @@
5455
b.demo_mode = False
5556
b.demo_sleep = 1
5657
b.message_duration = 2
58+
b.settings_file = None
5759
b.user_data_dir = None
5860
b.proxy_string = None
5961
b.ad_block_on = False

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pip>=19.2.2
2-
setuptools>=41.0.1
2+
setuptools>=41.1.0
33
wheel>=0.33.4
44
six
55
nose

seleniumbase/core/browser_launcher.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def _set_chrome_options(
110110
}
111111
chrome_options.add_experimental_option("prefs", prefs)
112112
chrome_options.add_experimental_option("w3c", True)
113+
chrome_options.add_experimental_option(
114+
"excludeSwitches", ["enable-automation"])
115+
chrome_options.add_experimental_option("useAutomationExtension", False)
113116
if enable_sync:
114117
chrome_options.add_experimental_option(
115118
"excludeSwitches", ["disable-sync"])
@@ -159,9 +162,10 @@ def _set_chrome_options(
159162
# https://bugs.chromium.org/p/chromium/issues/detail?id=706008
160163
chrome_options.add_argument("--headless")
161164
chrome_options.add_argument("--disable-gpu")
162-
chrome_options.add_argument("--no-sandbox")
163165
if "linux" in PLATFORM:
164-
chrome_options.add_argument("--disable-dev-shm-usage")
166+
chrome_options.add_argument("--no-sandbox")
167+
if "linux" in PLATFORM:
168+
chrome_options.add_argument("--disable-dev-shm-usage")
165169
return chrome_options
166170

167171

seleniumbase/fixtures/base_case.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2778,7 +2778,10 @@ def get_new_driver(self, browser=None, headless=None,
27782778
else:
27792779
if self.browser == 'chrome' or self.browser == 'opera':
27802780
try:
2781-
self.driver.set_window_size(1250, 840)
2781+
if self.maximize_window:
2782+
self.driver.maximize_window()
2783+
else:
2784+
self.driver.set_window_size(1250, 840)
27822785
self.wait_for_ready_state_complete()
27832786
except Exception:
27842787
pass # Keep existing browser resolution
@@ -3207,6 +3210,7 @@ def setUp(self, masterqa_mode=False):
32073210
self.user_data_dir = sb_config.user_data_dir
32083211
self.extension_zip = sb_config.extension_zip
32093212
self.extension_dir = sb_config.extension_dir
3213+
self.maximize_window = sb_config.maximize_window
32103214
self.save_screenshot_after_test = sb_config.save_screenshot
32113215
self.visual_baseline = sb_config.visual_baseline
32123216
self.timeout_multiplier = sb_config.timeout_multiplier

seleniumbase/plugins/pytest_plugin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def pytest_addoption(parser):
3939
--verify_delay=SECONDS (The delay before MasterQA verification checks.)
4040
--disable_csp (This disables the Content Security Policy of websites.)
4141
--enable_sync (The option to enable "Chrome Sync".)
42+
--maximize_window (The option to start with the web browser maximized.)
4243
--save_screenshot (The option to save a screenshot after each test.)
4344
--visual_baseline (Set the visual baseline for Visual/Layout tests.)
4445
--timeout_multiplier=MULTIPLIER (Multiplies the default timeout values.)
@@ -281,6 +282,13 @@ def pytest_addoption(parser):
281282
dest='enable_sync',
282283
default=False,
283284
help="""Using this enables the "Chrome Sync" feature.""")
285+
parser.addoption('--maximize_window', '--maximize-window', '--maximize',
286+
'--fullscreen',
287+
action="store_true",
288+
dest='maximize_window',
289+
default=False,
290+
help="""The option to start with the browser window
291+
maximized.""")
284292
parser.addoption('--save_screenshot', '--save-screenshot',
285293
action='store_true',
286294
dest='save_screenshot',
@@ -341,6 +349,7 @@ def pytest_configure(config):
341349
sb_config.verify_delay = config.getoption('verify_delay')
342350
sb_config.disable_csp = config.getoption('disable_csp')
343351
sb_config.enable_sync = config.getoption('enable_sync')
352+
sb_config.maximize_window = config.getoption('maximize_window')
344353
sb_config.save_screenshot = config.getoption('save_screenshot')
345354
sb_config.visual_baseline = config.getoption('visual_baseline')
346355
sb_config.timeout_multiplier = config.getoption('timeout_multiplier')

seleniumbase/plugins/selenium_plugin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class SeleniumBrowser(Plugin):
3131
--verify_delay=SECONDS (The delay before MasterQA verification checks.)
3232
--disable_csp (This disables the Content Security Policy of websites.)
3333
--enable_sync (The option to enable "Chrome Sync".)
34+
--maximize_window (The option to start with the web browser maximized.)
3435
--save_screenshot (The option to save a screenshot after each test.)
3536
--visual_baseline (Set the visual baseline for Visual/Layout tests.)
3637
--timeout_multiplier=MULTIPLIER (Multiplies the default timeout values.)
@@ -212,6 +213,13 @@ def options(self, parser, env):
212213
dest='enable_sync',
213214
default=False,
214215
help="""Using this enables the "Chrome Sync" feature.""")
216+
parser.add_option(
217+
'--maximize_window', '--maximize-window', '--maximize',
218+
'--fullscreen',
219+
action="store_true",
220+
dest='maximize_window',
221+
default=False,
222+
help="""The option to start with the web browser maximized.""")
215223
parser.add_option(
216224
'--save_screenshot', '--save-screenshot',
217225
action="store_true",
@@ -266,6 +274,7 @@ def beforeTest(self, test):
266274
test.test.verify_delay = self.options.verify_delay # MasterQA
267275
test.test.disable_csp = self.options.disable_csp
268276
test.test.enable_sync = self.options.enable_sync
277+
test.test.maximize_window = self.options.maximize_window
269278
test.test.save_screenshot_after_test = self.options.save_screenshot
270279
test.test.visual_baseline = self.options.visual_baseline
271280
test.test.timeout_multiplier = self.options.timeout_multiplier

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name='seleniumbase',
20-
version='1.28.3',
20+
version='1.29.0',
2121
description='Fast, Easy, and Reliable Browser Automation & Testing.',
2222
long_description=long_description,
2323
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)