Skip to content

Allow multiple file downloads without prompts #710

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 4 commits into from
Oct 2, 2020
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
113 changes: 72 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ Tests are run with <code><b>pytest</b></code>. Browsers are controlled by WebDri
<p align="center"><img src="https://cdn2.hubspot.net/hubfs/100006/images/swag_labs_gif.gif" alt="SeleniumBase" title="SeleniumBase" /></p>

<a id="python_installation"></a>
<h2><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Start 🚀:</h2>
<h2><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Start: 🚀</h2>

* Get **[Python](https://www.python.org/downloads/)** and **[Git](https://git-scm.com/)**
* Add **[Python](https://www.python.org/downloads/)** and **[Git](https://git-scm.com/)** to your System PATH.

Upgrade <b>[pip](https://pypi.org/project/pip/)</b> and create a [Python virtual environment](https://seleniumbase.io/help_docs/virtualenv_instructions/):
* Upgrade <b>[pip](https://pypi.org/project/pip/)</b> and create a [Python virtual env](https://seleniumbase.io/help_docs/virtualenv_instructions/):

* macOS/Linux:
> macOS/Linux (terminal):

```bash
python3 -m pip install -U pip
python3 -m venv sbase_env
source sbase_env/bin/activate
```

* Windows(Cmd):
> Windows (CMD prompt):

```bash
py -m pip install -U pip
Expand All @@ -83,35 +83,78 @@ call sbase_env\\Scripts\\activate
<a id="install_seleniumbase"></a>
<h2><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Install SeleniumBase:</h2>

You can install ``seleniumbase`` from [pypi](https://pypi.python.org/pypi/seleniumbase):
* You can install ``seleniumbase`` from [pypi](https://pypi.python.org/pypi/seleniumbase):

```bash
pip install seleniumbase
```

* Add ``--upgrade`` OR ``-U`` to upgrade an installation.
* Add ``--force-reinstall`` to also upgrade dependencies.
> (Add ``--upgrade`` OR ``-U`` to upgrade an installation.)
> (Add ``--force-reinstall`` to upgrade dependencies.)

You can also install SeleniumBase from a [GitHub](https://github.com/seleniumbase/SeleniumBase) clone:
* You can also install SeleniumBase from a [GitHub](https://github.com/seleniumbase/SeleniumBase) clone:

```bash
git clone https://github.com/seleniumbase/SeleniumBase.git
cd SeleniumBase/
pip install .
```

* Type ``seleniumbase`` or ``sbase`` to verify that SeleniumBase was installed successfully:

```bash
______ __ _ ____
/ ____/__ / /__ ____ (_)_ ______ ___ / _ \____ ________
\__ \/ _ \/ / _ \/ __ \/ / / / / __ `__ \/ /_) / __ \/ ___/ _ \
___/ / __/ / __/ / / / / /_/ / / / / / / /_) / (_/ /__ / __/
/____/\___/_/\___/_/ /_/_/\__,_/_/ /_/ /_/_____/\__,_/____/\___/

[seleniumbase <VERSION> (<PATH>)]

* USAGE: "seleniumbase [COMMAND] [PARAMETERS]"
* OR: "sbase [COMMAND] [PARAMETERS]"

COMMANDS:
install [DRIVER] [OPTIONS]
mkdir [DIRECTORY]
mkfile [FILE.py]
options (List common pytest options)
print [FILE] [OPTIONS]
translate [SB_FILE.py] [LANG] [ACTION]
convert [WEBDRIVER_UNITTEST_FILE.py]
extract-objects [SB_FILE.py]
inject-objects [SB_FILE.py] [OPTIONS]
objectify [SB_FILE.py] [OPTIONS]
revert-objects [SB_FILE.py]
encrypt (OR: obfuscate)
decrypt (OR: unobfuscate)
download server (Selenium Server JAR file)
grid-hub [start|stop] [OPTIONS]
grid-node [start|stop] --hub=[HOST/IP]
* (EXAMPLE: "sbase install chromedriver latest") *

Type "sbase help [COMMAND]" for specific command info.
For info on all commands, type: "seleniumbase --help".
* (Use "pytest" for running tests) *
```

<h3><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Download a webdriver:</h3>

SeleniumBase can download webdrivers to the [seleniumbase/drivers](https://github.com/seleniumbase/SeleniumBase/tree/master/seleniumbase/drivers) folder with the ``install`` command:

```bash
sbase install chromedriver
```
* You need a different webdriver for each browser: ``chromedriver`` for Chrome, ``edgedriver`` for Edge, ``geckodriver`` for Firefox, and ``operadriver`` for Opera.

* You need a different webdriver for each browser to automate: ``chromedriver`` for Chrome, ``edgedriver`` for Edge, ``geckodriver`` for Firefox, and ``operadriver`` for Opera.
* If you have the latest version of Chrome installed, get the latest chromedriver (<i>otherwise it defaults to chromedriver 2.44 for compatibility reasons</i>):

```bash
sbase install chromedriver latest
```

* If you run a test without the correct webdriver installed, the driver will be downloaded automatically.

(See [seleniumbase.io/seleniumbase/console_scripts/ReadMe/](https://seleniumbase.io/seleniumbase/console_scripts/ReadMe/) for more information on SeleniumBase console scripts.)

<h3><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Create and run tests:</h3>
Expand All @@ -123,7 +166,20 @@ sbase mkdir ui_tests
cd ui_tests/
```

* Now run a sample test with ``pytest``:
> This folder contains the following files:

```
__init__.py
boilerplates/
my_first_test.py
parameterized_test.py
pytest.ini
requirements.txt
setup.cfg
test_demo_site.py
```

* <b>Run a sample test with ``pytest``:</b>

```bash
pytest test_demo_site.py
Expand Down Expand Up @@ -259,31 +315,6 @@ For a full list of SeleniumBase features, <a href="https://github.com/seleniumba

<h2><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Detailed Instructions:</h2>

<h4><b>Here's how to run the example script on various web browsers:</b></h4>

First install a webdriver for each browser you intend to use:

```bash
seleniumbase install chromedriver
seleniumbase install geckodriver
seleniumbase install edgedriver
seleniumbase install iedriver
seleniumbase install operadriver
```

Next, choose between ``pytest`` and ``nosetests`` test runners. (<i>Mostly interchangeable.</i>)

```bash
cd examples/

pytest my_first_test.py --browser=chrome

nosetests my_first_test.py --browser=firefox
```

(<i>If no browser is specified, Chrome is used by default.</i>)
With Pytest, a green dot means a test passed. An "F" means a test failed.

<a id="seleniumbase_demo_mode"></a> <b>Use Demo Mode to help you see what tests are asserting.</b>

If the example test is moving too fast for your eyes, you can run it in **Demo Mode** by adding ``--demo`` on the command-line, which pauses the browser briefly between actions, highlights page elements being acted on, and lets you know what test assertions are happening in real time:
Expand Down Expand Up @@ -404,7 +435,7 @@ Here's the command-line option to add to tests: (See [examples/custom_settings.p
(Settings include default timeout values, a two-factor auth key, DB credentials, S3 credentials, and other important settings used by tests.)

To pass additional data from the command-line to tests, add ``--data="ANY STRING"``.
Now inside your tests, you can use ``self.data`` to access that.
Inside your tests, you can use ``self.data`` to access that.


<h3><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Test Directory Customization:</h3>
Expand Down Expand Up @@ -524,22 +555,22 @@ Learn about <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/ex
<a id="utilizing_advanced_features"></a>
<h3><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Production Environments & Integrations:</h3>

Here are some things you can do to setup a production environment for your testing:
Here are some things you can do to set up a production environment for your testing:

* You can setup a [Jenkins](https://jenkins.io/) build server for running tests at regular intervals. For a real-world Jenkins example of headless browser automation in action, check out the <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/azure/jenkins/ReadMe.md">SeleniumBase Jenkins example on Azure</a> or the <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/google_cloud/ReadMe.md">SeleniumBase Jenkins example on Google Cloud</a>.
* You can set up a [Jenkins](https://jenkins.io/) build server for running tests at regular intervals. For a real-world Jenkins example of headless browser automation in action, check out the <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/azure/jenkins/ReadMe.md">SeleniumBase Jenkins example on Azure</a> or the <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/google_cloud/ReadMe.md">SeleniumBase Jenkins example on Google Cloud</a>.

* You can use [the Selenium Grid](https://selenium.dev/documentation/en/grid/) to scale your testing by distributing tests on several machines with parallel execution. To do this, check out the [SeleniumBase selenium_grid folder](https://github.com/seleniumbase/SeleniumBase/tree/master/seleniumbase/utilities/selenium_grid), which should have everything you need, including the <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md">Selenium Grid ReadMe</a>, which will help you get started.

* If you're using the <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/mysql_installation.md">SeleniumBase MySQL feature</a> to save results from tests running on a server machine, you can install [MySQL Workbench](https://dev.mysql.com/downloads/tools/workbench/) to help you read & write from your DB more easily.

* If you use [Slack](https://slack.com), you can easily have your Jenkins jobs display results there by using the [Jenkins Slack Plugin](https://github.com/jenkinsci/slack-plugin). Another way to send messages from your tests to Slack is by using [Slack's Incoming Webhooks API](https://api.slack.com/incoming-webhooks).

* If you're using AWS, you can setup an [Amazon S3](https://aws.amazon.com/s3/) account for saving log files and screenshots from your tests. To activate this feature, modify [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) with connection details in the S3 section, and add "``--with-s3-logging``" on the command-line when running your tests.
* If you're using AWS, you can set up an [Amazon S3](https://aws.amazon.com/s3/) account for saving log files and screenshots from your tests. To activate this feature, modify [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) with connection details in the S3 section, and add "``--with-s3-logging``" on the command-line when running your tests.

Here's an example of running tests with additional features enabled:

```bash
pytest [YOUR_TEST_FILE].py --with-db-reporting --with-s3-logging
pytest [YOUR_TEST_FILE.py] --with-db-reporting --with-s3-logging
```

<a id="detailed_method_specifications"></a>
Expand Down
2 changes: 1 addition & 1 deletion examples/translations/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h3 align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_m.png" title="SeleniumBase" width="290" /></a></h3>
<h3 align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/super_logo_m.png" title="SeleniumBase" width="290" /></a></h3>

<a id="language_tests"></a>
<h3><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Language Tests (Python 3+)</h3>
Expand Down
3 changes: 1 addition & 2 deletions help_docs/mobile_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ pytest test_swag_labs.py --mobile --agent="Mozilla/5.0 (Linux; Android 9; Pixel
--------

<p align="center"><div align="center"><a href="https://seleniumbase.io">
<img src="https://img.shields.io/badge/docs-%20📓📖📚-11BBDD.svg" alt="SeleniumBase.io Docs" />
</a> <a href="https://github.com/seleniumbase/SeleniumBase"><img src="https://img.shields.io/badge/✅%20💛%20View%20Code-on%20GitHub%20🌎%20🚀-02A79E.svg" alt="SeleniumBase.io Docs" /></a></div></p>
<img src="https://img.shields.io/badge/docs-%20seleniumbase.io-11BBDD.svg" alt="SeleniumBase.io Docs" /></a> <a href="https://github.com/seleniumbase/SeleniumBase"><img src="https://img.shields.io/badge/✅%20💛%20View%20Code-on%20GitHub%20🌎%20🚀-02A79E.svg" alt="SeleniumBase.io Docs" /></a></div></p>
2 changes: 1 addition & 1 deletion help_docs/translations.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h3 align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_m.png" title="SeleniumBase" width="290" /></a></h3>
<h3 align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/super_logo_m.png" title="SeleniumBase" width="290" /></a></h3>

<a id="language_tests"></a>
<h3><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Language Tests (Python 3+)</h3>
Expand Down
7 changes: 4 additions & 3 deletions seleniumbase/config/proxy_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
"""

PROXY_LIST = {
"example1": "46.28.229.75:3128", # (Example) - set your own proxy here
"example2": "82.200.233.4:3128", # (Example) - set your own proxy here
"example3": "128.199.214.87:3128", # (Example) - set your own proxy here
"example1": "45.133.182.18:18080", # (Example) - set your own proxy here
"example2": "95.174.67.50:18080", # (Example) - set your own proxy here
"example3": "83.97.23.90:18080", # (Example) - set your own proxy here
"example4": "82.200.233.4:3128", # (Example) - set your own proxy here
"proxy1": None,
"proxy2": None,
"proxy3": None,
Expand Down
23 changes: 11 additions & 12 deletions seleniumbase/console_scripts/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,6 @@ is included.
Displays common pytest command-line options
that are available when using SeleniumBase.

### convert

* Usage:
``sbase convert [WEBDRIVER_UNITTEST_FILE.py]``

* Output:
Converts a Selenium IDE exported WebDriver unittest file
into a SeleniumBase file. Adds ``_SB`` to the new
file name while keeping the original file intact.
Works with Katalon Recorder scripts.
See: http://www.katalon.com/automation-recorder

### print

* Usage:
Expand Down Expand Up @@ -142,6 +130,17 @@ plus the 2-letter language code of the new language.
(Example: Translating "test_1.py" into Japanese with
``-c`` will create a new file called "test_1_ja.py".)

### convert

* Usage:
``sbase convert [WEBDRIVER_UNITTEST_FILE.py]``

* Output:
Converts a Selenium IDE exported WebDriver unittest file
into a SeleniumBase file. Adds ``_SB`` to the new
file name while keeping the original file intact.
Works with Katalon Recorder scripts.
See: http://www.katalon.com/automation-recorder

### extract-objects

Expand Down
7 changes: 5 additions & 2 deletions seleniumbase/console_scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def show_basic_usage():
sc += (" mkdir [DIRECTORY]\n")
sc += (" mkfile [FILE.py]\n")
sc += (" options (List common pytest options)\n")
sc += (" convert [WEBDRIVER_UNITTEST_FILE.py]\n")
sc += (" print [FILE] [OPTIONS]\n")
sc += (" translate [SB_FILE.py] [LANG] [ACTION]\n")
sc += (" convert [WEBDRIVER_UNITTEST_FILE.py]\n")
sc += (" extract-objects [SB_FILE.py]\n")
sc += (" inject-objects [SB_FILE.py] [OPTIONS]\n")
sc += (" objectify [SB_FILE.py] [OPTIONS]\n")
Expand Down Expand Up @@ -107,10 +107,13 @@ def show_install_usage():
print(" Example:")
print(" sbase install chromedriver")
print(" sbase install geckodriver")
print(" sbase install chromedriver 83.0.4103.39")
print(" sbase install edgedriver")
print(" sbase install chromedriver 85")
print(" sbase install chromedriver 85.0.4183.87")
print(" sbase install chromedriver latest")
print(" sbase install chromedriver -p")
print(" sbase install chromedriver latest -p")
print(" sbase install edgedriver 85.0.564.68")
print(" Output:")
print(" Installs the chosen webdriver to seleniumbase/drivers/")
print(" (chromedriver is required for Chrome automation)")
Expand Down
24 changes: 12 additions & 12 deletions seleniumbase/console_scripts/sb_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
Installs the specified web driver.

Usage:
seleniumbase install {chromedriver|geckodriver|edgedriver|
iedriver|operadriver} [OPTIONS]
sbase install {chromedriver|geckodriver|edgedriver|
iedriver|operadriver} [OPTIONS]
Options:
VERSION Specify the version.
(Default chromedriver version = 2.44)
Use "latest" for the latest version.
-p OR --path Also copy the driver to /usr/local/bin
Example:
seleniumbase install chromedriver
seleniumbase install geckodriver
seleniumbase install edgedriver
seleniumbase install edgedriver 84.0.522.61
seleniumbase install chromedriver 84
seleniumbase install chromedriver 84.0.4147.30
seleniumbase install chromedriver latest
seleniumbase install chromedriver -p
seleniumbase install chromedriver latest -p
sbase install chromedriver
sbase install geckodriver
sbase install edgedriver
sbase install chromedriver 85.0.4183.87
sbase install chromedriver 85
sbase install chromedriver latest
sbase install chromedriver -p
sbase install chromedriver latest -p
sbase install edgedriver 85.0.564.68
Output:
Installs the chosen webdriver to seleniumbase/drivers/
(chromedriver is required for Chrome automation)
(geckodriver is required for Firefox automation)
(edgedriver is required for MS Edge automation)
(iedriver is required for Internet Explorer automation)
(operadriver is required for Opera Browser automation)
(iedriver is required for Internet Explorer automation)
"""

import colorama
Expand Down
12 changes: 10 additions & 2 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ def _set_chrome_options(
"safebrowsing.disable_download_protection": True,
"profile": {
"password_manager_enabled": False,
"default_content_setting_values.automatic_downloads": 1
"default_content_setting_values.automatic_downloads": 1,
"managed_default_content_settings.automatic_downloads": 1,
"default_content_settings.popups": 0,
"managed_default_content_settings.popups": 0,
"content_settings.exceptions.automatic_downloads.*.setting": 1,
"content_settings.pattern_pairs.*.multiple-automatic-downloads": 1
}
}
if locale_code:
Expand Down Expand Up @@ -766,7 +771,10 @@ def get_local_driver(
"safebrowsing.disable_download_protection": True,
"profile": {
"password_manager_enabled": False,
"default_content_setting_values.automatic_downloads": 1
"default_content_setting_values.automatic_downloads": 1,
"managed_default_content_settings.automatic_downloads": 1,
"default_content_settings.popups": 0,
"managed_default_content_settings.popups": 0
}
}
if locale_code:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

setup(
name='seleniumbase',
version='1.49.22',
version='1.49.23',
description='A complete framework for Web-UI testing | seleniumbase.io',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down