From 2458e34b38c770596b1f5cb901abdc749d1859a0 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Fri, 2 Oct 2020 13:23:21 -0400 Subject: [PATCH 1/4] Allow multiple downloads without prompts --- seleniumbase/core/browser_launcher.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/seleniumbase/core/browser_launcher.py b/seleniumbase/core/browser_launcher.py index dc87d1a046e..c1c559882f2 100755 --- a/seleniumbase/core/browser_launcher.py +++ b/seleniumbase/core/browser_launcher.py @@ -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: @@ -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: From a7c40b43d90f32d0da4de1389d859865ae283180 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Fri, 2 Oct 2020 13:24:20 -0400 Subject: [PATCH 2/4] Update the proxy list examples --- seleniumbase/config/proxy_list.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/seleniumbase/config/proxy_list.py b/seleniumbase/config/proxy_list.py index 72f0adbedd6..53b039409af 100755 --- a/seleniumbase/config/proxy_list.py +++ b/seleniumbase/config/proxy_list.py @@ -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, From 626b9fc0d1ae2a60732a6729625456880a4ad89a Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Fri, 2 Oct 2020 13:25:12 -0400 Subject: [PATCH 3/4] Update the docs --- README.md | 113 +++++++++++++-------- examples/translations/ReadMe.md | 2 +- help_docs/mobile_testing.md | 3 +- help_docs/translations.md | 2 +- seleniumbase/console_scripts/ReadMe.md | 23 ++--- seleniumbase/console_scripts/run.py | 7 +- seleniumbase/console_scripts/sb_install.py | 24 ++--- 7 files changed, 103 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index bb0bded4bfd..fc3d3df06d2 100755 --- a/README.md +++ b/README.md @@ -58,13 +58,13 @@ Tests are run with pytest. Browsers are controlled by WebDri

SeleniumBase

-

Start 🚀:

+

Start: 🚀

-* 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 [pip](https://pypi.org/project/pip/) and create a [Python virtual environment](https://seleniumbase.io/help_docs/virtualenv_instructions/): +* Upgrade [pip](https://pypi.org/project/pip/) 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 @@ -72,7 +72,7 @@ python3 -m venv sbase_env source sbase_env/bin/activate ``` -* Windows(Cmd): +> Windows (CMD prompt): ```bash py -m pip install -U pip @@ -83,16 +83,16 @@ call sbase_env\\Scripts\\activate

Install SeleniumBase:

-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 @@ -100,18 +100,61 @@ cd SeleniumBase/ pip install . ``` +* Type ``seleniumbase`` or ``sbase`` to verify that SeleniumBase was installed successfully: + +```bash + ______ __ _ ____ + / ____/__ / /__ ____ (_)_ ______ ___ / _ \____ ________ + \__ \/ _ \/ / _ \/ __ \/ / / / / __ `__ \/ /_) / __ \/ ___/ _ \ + ___/ / __/ / __/ / / / / /_/ / / / / / / /_) / (_/ /__ / __/ +/____/\___/_/\___/_/ /_/_/\__,_/_/ /_/ /_/_____/\__,_/____/\___/ + +[seleniumbase ()] + + * 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) * +``` +

Download a webdriver:

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 (otherwise it defaults to chromedriver 2.44 for compatibility reasons): + ```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.)

Create and run tests:

@@ -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 +``` + +* Run a sample test with ``pytest``: ```bash pytest test_demo_site.py @@ -259,31 +315,6 @@ For a full list of SeleniumBase features, Detailed Instructions: -

Here's how to run the example script on various web browsers:

- -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. (Mostly interchangeable.) - -```bash -cd examples/ - -pytest my_first_test.py --browser=chrome - -nosetests my_first_test.py --browser=firefox -``` - -(If no browser is specified, Chrome is used by default.) -With Pytest, a green dot means a test passed. An "F" means a test failed. -
Use Demo Mode to help you see what tests are asserting. 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: @@ -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.

Test Directory Customization:

@@ -524,9 +555,9 @@ Learn about

Production Environments & Integrations:

-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 SeleniumBase Jenkins example on Azure or the SeleniumBase Jenkins example on Google Cloud. +* 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 SeleniumBase Jenkins example on Azure or the SeleniumBase Jenkins example on Google Cloud. * 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 Selenium Grid ReadMe, which will help you get started. @@ -534,12 +565,12 @@ Here are some things you can do to setup a production environment for your testi * 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 ``` diff --git a/examples/translations/ReadMe.md b/examples/translations/ReadMe.md index 184adcfd6d8..14743485e87 100755 --- a/examples/translations/ReadMe.md +++ b/examples/translations/ReadMe.md @@ -1,4 +1,4 @@ -

+

Language Tests (Python 3+)

diff --git a/help_docs/mobile_testing.md b/help_docs/mobile_testing.md index f262c41388c..20cfb10cebe 100755 --- a/help_docs/mobile_testing.md +++ b/help_docs/mobile_testing.md @@ -48,5 +48,4 @@ pytest test_swag_labs.py --mobile --agent="Mozilla/5.0 (Linux; Android 9; Pixel --------

+SeleniumBase.io Docs SeleniumBase.io Docs

diff --git a/help_docs/translations.md b/help_docs/translations.md index 184adcfd6d8..14743485e87 100755 --- a/help_docs/translations.md +++ b/help_docs/translations.md @@ -1,4 +1,4 @@ -

+

Language Tests (Python 3+)

diff --git a/seleniumbase/console_scripts/ReadMe.md b/seleniumbase/console_scripts/ReadMe.md index f0510eb687e..66a1f88a46a 100755 --- a/seleniumbase/console_scripts/ReadMe.md +++ b/seleniumbase/console_scripts/ReadMe.md @@ -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: @@ -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 diff --git a/seleniumbase/console_scripts/run.py b/seleniumbase/console_scripts/run.py index 20a0724d85c..75618875a0f 100644 --- a/seleniumbase/console_scripts/run.py +++ b/seleniumbase/console_scripts/run.py @@ -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") @@ -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)") diff --git a/seleniumbase/console_scripts/sb_install.py b/seleniumbase/console_scripts/sb_install.py index 9fe4eba685b..7615baef558 100755 --- a/seleniumbase/console_scripts/sb_install.py +++ b/seleniumbase/console_scripts/sb_install.py @@ -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 From f297b8cfa12072788f9c71e2ce0c098e13d7a375 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Fri, 2 Oct 2020 13:25:48 -0400 Subject: [PATCH 4/4] Version 1.49.23 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c0fcd82f08d..211e82c3804 100755 --- a/setup.py +++ b/setup.py @@ -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',