diff --git a/examples/test_chromedriver.py b/examples/test_chromedriver.py index 9e664130405..7faa2029e20 100644 --- a/examples/test_chromedriver.py +++ b/examples/test_chromedriver.py @@ -1,7 +1,6 @@ """This test is only for Chrome! (Verify that your chromedriver is compatible with your version of Chrome.)""" import colorama -import sys from seleniumbase import BaseCase BaseCase.main(__name__, __file__) @@ -16,13 +15,6 @@ def test_chromedriver_matches_chrome(self): major_chrome_version = chrome_version.split(".")[0] chromedriver_version = self.get_chromedriver_version() major_chromedriver_version = chromedriver_version.split(".")[0] - if ( - "win32" in sys.platform - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX diff --git a/seleniumbase/__init__.py b/seleniumbase/__init__.py index 0f536be75ab..a57a5b5df9d 100644 --- a/seleniumbase/__init__.py +++ b/seleniumbase/__init__.py @@ -1,21 +1,18 @@ import collections import os import pdb -try: - import pdbp # (Pdb+) --- Python Debugger Plus -except Exception: - pass import sys +from contextlib import suppress from selenium import webdriver from seleniumbase.__version__ import __version__ from seleniumbase.common import decorators # noqa from seleniumbase.common import encryption # noqa -from seleniumbase.core import colored_traceback # noqa +from seleniumbase.core import colored_traceback from seleniumbase.core.browser_launcher import get_driver # noqa from seleniumbase.fixtures import js_utils # noqa from seleniumbase.fixtures import page_actions # noqa from seleniumbase.fixtures import page_utils # noqa -from seleniumbase.fixtures import shared_utils # noqa +from seleniumbase.fixtures import shared_utils from seleniumbase.fixtures.base_case import BaseCase # noqa from seleniumbase.masterqa.master_qa import MasterQA # noqa from seleniumbase.plugins.sb_manager import SB # noqa @@ -23,6 +20,17 @@ from seleniumbase.plugins.driver_manager import DriverContext # noqa from seleniumbase import translate # noqa +with suppress(Exception): + import colorama + import pdbp # (Pdb+) --- Python Debugger Plus + +is_windows = shared_utils.is_windows() +with suppress(Exception): + if is_windows and hasattr(colorama, "just_fix_windows_console"): + colorama.just_fix_windows_console() + elif not shared_utils.is_linux(): + colorama.init(autoreset=True) + if sys.version_info[0] < 3 and "pdbp" in locals(): # With Python3, "import pdbp" is all you need for key in pdbp.__dict__.keys(): diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index 29332d95247..f5085aaef2b 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "4.31.4" +__version__ = "4.31.5" diff --git a/seleniumbase/behave/behave_sb.py b/seleniumbase/behave/behave_sb.py index 81f1fb8f098..6274432b838 100644 --- a/seleniumbase/behave/behave_sb.py +++ b/seleniumbase/behave/behave_sb.py @@ -1231,10 +1231,6 @@ def behave_dashboard_prepare(): c1 = "" cr = "" if not is_linux: - if is_windows and hasattr(colorama, "just_fix_windows_console"): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX cr = colorama.Style.RESET_ALL print("Dashboard: %s%s%s\n%s" % (c1, dash_path, cr, stars)) @@ -1346,10 +1342,6 @@ def _perform_behave_terminal_summary_(): c2 = "" cr = "" if not is_linux: - if is_windows and hasattr(colorama, "just_fix_windows_console"): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c2 = colorama.Fore.MAGENTA + colorama.Back.LIGHTYELLOW_EX cr = colorama.Style.RESET_ALL if sb_config.dashboard: diff --git a/seleniumbase/console_scripts/logo_helper.py b/seleniumbase/console_scripts/logo_helper.py index a9d053d666e..e85f19bbaff 100644 --- a/seleniumbase/console_scripts/logo_helper.py +++ b/seleniumbase/console_scripts/logo_helper.py @@ -4,7 +4,6 @@ import colorama import os -import sys from contextlib import suppress r""" @@ -17,13 +16,6 @@ def get_seleniumbase_logo(): - if ( - "win32" in sys.platform - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX c3 = colorama.Back.CYAN diff --git a/seleniumbase/console_scripts/run.py b/seleniumbase/console_scripts/run.py index 7f62f7cdd2c..f8809f3dd92 100644 --- a/seleniumbase/console_scripts/run.py +++ b/seleniumbase/console_scripts/run.py @@ -45,86 +45,71 @@ from seleniumbase.fixtures import constants from seleniumbase.fixtures import shared_utils -if shared_utils.is_windows() and hasattr(colorama, "just_fix_windows_console"): - colorama.just_fix_windows_console() -else: - colorama.init(autoreset=True) - - -def show_usage(): - show_basic_usage() - sc = "" - sc += ' Type "sbase help [COMMAND]" for specific info.\n' - sc += ' For all commands, type: "seleniumbase --help".\n' - sc += ' Use "pytest" for running tests.\n' - if "linux" not in sys.platform: - c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX - c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX - c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX - c4 = colorama.Fore.MAGENTA + colorama.Back.LIGHTYELLOW_EX - cr = colorama.Style.RESET_ALL - sc = sc.replace("seleniumbase", c1 + "selenium" + c2 + "base" + cr) - sc = sc.replace("sbase", c1 + "s" + c2 + "base" + cr) - sc = sc.replace("pytest", c3 + "pytest" + cr) - sc = sc.replace("--help", c4 + "--help" + cr) - sc = sc.replace("help", c4 + "help" + cr) - print(sc) - def show_basic_usage(): from seleniumbase.console_scripts import logo_helper seleniumbase_logo = logo_helper.get_seleniumbase_logo() print(seleniumbase_logo) - time.sleep(0.044) + time.sleep(0.035) print("") - time.sleep(0.033) + time.sleep(0.031) show_package_location() - time.sleep(0.032) + time.sleep(0.031) show_version_info() time.sleep(0.031) print("") - time.sleep(0.68) # Enough time to see the logo & version + time.sleep(0.555) # Enough time to see the logo & version sc = "" - sc += ' * USAGE: "seleniumbase [COMMAND] [PARAMETERS]"\n' - sc += ' * OR: "sbase [COMMAND] [PARAMETERS]"\n' - sc += "\n" - sc += "COMMANDS:\n" - sc += " get / install [DRIVER] [OPTIONS]\n" - sc += " methods (List common Python methods)\n" - sc += " options (List common pytest options)\n" - sc += " behave-options (List common behave options)\n" - sc += " gui / commander [OPTIONAL PATH or TEST FILE]\n" - sc += " behave-gui (SBase Commander for Behave)\n" - sc += " caseplans [OPTIONAL PATH or TEST FILE]\n" - sc += " mkdir [DIRECTORY] [OPTIONS]\n" - sc += " mkfile [FILE.py] [OPTIONS]\n" - sc += " mkrec / codegen [FILE.py] [OPTIONS]\n" - sc += " recorder (Open Recorder Desktop App.)\n" - sc += " record (If args: mkrec. Else: App.)\n" - sc += " mkpres [FILE.py] [LANG]\n" - sc += " mkchart [FILE.py] [LANG]\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" - sc += " revert-objects [SB_FILE.py] [OPTIONS]\n" - sc += " encrypt / obfuscate\n" - sc += " decrypt / unobfuscate\n" - sc += " proxy (Start a basic proxy server)\n" - sc += " download server (Get Selenium Grid JAR file)\n" - sc += " grid-hub [start|stop] [OPTIONS]\n" - sc += " grid-node [start|stop] --hub=[HOST/IP]\n" - sc += ' * (EXAMPLE: "sbase get chromedriver") *\n' + sc += "╭──────────────────────────────────────────────────╮\n" + sc += '│ * USAGE: "seleniumbase [COMMAND] [PARAMETERS]" │\n' + sc += '│ * OR: "sbase [COMMAND] [PARAMETERS]" │\n' + sc += "│ │\n" + sc += "│ COMMANDS: PARAMETERS / DESCRIPTIONS: │\n" + sc += "│ get / install [DRIVER_NAME] [OPTIONS] │\n" + sc += "│ methods (List common Python methods) │\n" + sc += "│ options (List common pytest options) │\n" + sc += "│ behave-options (List common behave options) │\n" + sc += "│ gui / commander [OPTIONAL PATH or TEST FILE] │\n" + sc += "│ behave-gui (SBase Commander for Behave) │\n" + sc += "│ caseplans [OPTIONAL PATH or TEST FILE] │\n" + sc += "│ mkdir [DIRECTORY] [OPTIONS] │\n" + sc += "│ mkfile [FILE.py] [OPTIONS] │\n" + sc += "│ mkrec / codegen [FILE.py] [OPTIONS] │\n" + sc += "│ recorder (Open Recorder Desktop App.) │\n" + sc += "│ record (If args: mkrec. Else: App.) │\n" + sc += "│ mkpres [FILE.py] [LANG] │\n" + sc += "│ mkchart [FILE.py] [LANG] │\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" + sc += "│ revert-objects [SB_FILE.py] [OPTIONS] │\n" + sc += "│ encrypt / obfuscate │\n" + sc += "│ decrypt / unobfuscate │\n" + sc += "│ proxy (Start a basic proxy server) │\n" + sc += "│ download server (Get Selenium Grid JAR file) │\n" + sc += "│ grid-hub [start|stop] [OPTIONS] │\n" + sc += "│ grid-node [start|stop] --hub=[HOST/IP] │\n" + sc += "│ │\n" + sc += '│ * EXAMPLE => "sbase get chromedriver stable" │\n' + sc += '│ * For command info => "sbase help [COMMAND]" │\n' + sc += '│ * For info on all commands => "sbase --help" │\n' + sc += "╰──────────────────────────────────────────────────╯" sc += "" if "linux" not in sys.platform: c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX + c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX + c4 = colorama.Fore.MAGENTA + colorama.Back.LIGHTYELLOW_EX cr = colorama.Style.RESET_ALL sc = sc.replace("seleniumbase", c1 + "selenium" + c2 + "base" + cr) sc = sc.replace("sbase", c1 + "s" + c2 + "base" + cr) + sc = sc.replace("[COMMAND]", c3 + "[COMMAND]" + cr) + sc = sc.replace("--help", c4 + "--help" + cr) + sc = sc.replace("help", c4 + "help" + cr) print(sc) @@ -136,33 +121,33 @@ def show_install_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase install [DRIVER_NAME] [OPTIONS]") - print(" OR: seleniumbase get [DRIVER_NAME] [OPTIONS]") - print(" OR: sbase install [DRIVER_NAME] [OPTIONS]") - print(" OR: sbase get [DRIVER_NAME] [OPTIONS]") - print(" (Drivers: chromedriver, geckodriver, edgedriver") - print(" iedriver, uc_driver)") + print(" seleniumbase install [DRIVER_NAME] [OPTIONS]") + print(" OR: seleniumbase get [DRIVER_NAME] [OPTIONS]") + print(" OR: sbase install [DRIVER_NAME] [OPTIONS]") + print(" OR: sbase get [DRIVER_NAME] [OPTIONS]") + print(" (Drivers: chromedriver, geckodriver,") + print(" edgedriver, iedriver, uc_driver)") print(" Options:") - print(" VERSION Specify the version to download.") - print(" Tries to detect the needed version.") - print(" If using chromedriver or edgedriver,") - print(" you can use the major version integer.") + print(" VERSION Specify the version to download.") + print(" Tries to detect the needed version.") + print(" If using chromedriver or edgedriver,") + print(" you can use the major version integer.") print() - print(" -p OR --path Also copy the driver to /usr/local/bin") + print(" -p / --path Also copy driver to /usr/local/bin") print(" Examples:") - print(" sbase get chromedriver") - print(" sbase get geckodriver") - print(" sbase get edgedriver") - print(" sbase get chromedriver 114") - print(" sbase get chromedriver 114.0.5735.90") - print(" sbase get chromedriver stable") - print(" sbase get chromedriver beta") - print(" sbase get chromedriver -p") + print(" sbase get chromedriver") + print(" sbase get geckodriver") + print(" sbase get edgedriver") + print(" sbase get chromedriver 114") + print(" sbase get chromedriver 114.0.5735.90") + print(" sbase get chromedriver stable") + print(" sbase get chromedriver beta") + print(" sbase get chromedriver -p") print(" Output:") - print(" Downloads the webdriver to seleniumbase/drivers/") - print(" (chromedriver is required for Chrome automation)") - print(" (geckodriver is required for Firefox automation)") - print(" (edgedriver is required for MS__Edge automation)") + print(" Downloads the webdriver to seleniumbase/drivers/") + print(" (chromedriver is required for Chrome automation)") + print(" (geckodriver is required for Firefox automation)") + print(" (edgedriver is required for MS__Edge automation)") print("") @@ -174,18 +159,18 @@ def show_commander_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase commander [OPTIONAL PATH or TEST FILE]") - print(" OR: sbase commander [OPTIONAL PATH or TEST FILE]") - print(" OR: seleniumbase gui [OPTIONAL PATH or TEST FILE]") - print(" OR: sbase gui [OPTIONAL PATH or TEST FILE]") + print(" seleniumbase commander [OPTIONAL PATH or TEST FILE]") + print(" OR: sbase commander [OPTIONAL PATH or TEST FILE]") + print(" OR: seleniumbase gui [OPTIONAL PATH or TEST FILE]") + print(" OR: sbase gui [OPTIONAL PATH or TEST FILE]") print(" Examples:") - print(" sbase gui") - print(" sbase gui -k agent") - print(" sbase gui -m marker2") - print(" sbase gui test_suite.py") - print(" sbase gui offline_examples/") + print(" sbase gui") + print(" sbase gui -k agent") + print(" sbase gui -m marker2") + print(" sbase gui test_suite.py") + print(" sbase gui offline_examples/") print(" Output:") - print(" Launches SeleniumBase Commander | GUI for pytest.") + print(" Launches SeleniumBase Commander | GUI for pytest.") print("") @@ -197,16 +182,16 @@ def show_behave_gui_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase behave-gui [OPTIONAL PATH or TEST FILE]") - print(" seleniumbase gui-behave [OPTIONAL PATH or TEST FILE]") - print(" OR: sbase behave-gui [OPTIONAL PATH or TEST FILE]") - print(" OR: sbase gui-behave [OPTIONAL PATH or TEST FILE]") + print(" seleniumbase behave-gui [OPTIONAL PATH or TEST FILE]") + print(" seleniumbase gui-behave [OPTIONAL PATH or TEST FILE]") + print(" OR: sbase behave-gui [OPTIONAL PATH or TEST FILE]") + print(" OR: sbase gui-behave [OPTIONAL PATH or TEST FILE]") print(" Examples:") - print(" sbase behave-gui") - print(" sbase behave-gui features/") - print(" sbase behave-gui features/calculator.feature") + print(" sbase behave-gui") + print(" sbase behave-gui features/") + print(" sbase behave-gui features/calculator.feature") print(" Output:") - print(" Launches SeleniumBase Commander | GUI for Behave.") + print(" Launches SeleniumBase Commander | GUI for Behave.") print("") @@ -218,16 +203,16 @@ def show_caseplans_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase caseplans [OPTIONAL PATH or TEST FILE]") - print(" OR: sbase caseplans [OPTIONAL PATH or TEST FILE]") + print(" seleniumbase caseplans [OPTIONAL PATH or TEST FILE]") + print(" OR: sbase caseplans [OPTIONAL PATH or TEST FILE]") print(" Examples:") - print(" sbase caseplans") - print(" sbase caseplans -k agent") - print(" sbase caseplans -m marker2") - print(" sbase caseplans test_suite.py") - print(" sbase caseplans offline_examples/") + print(" sbase caseplans") + print(" sbase caseplans -k agent") + print(" sbase caseplans -m marker2") + print(" sbase caseplans test_suite.py") + print(" sbase caseplans offline_examples/") print(" Output:") - print(" Launches the SeleniumBase Case Plans Generator.") + print(" Launches the SeleniumBase Case Plans Generator.") print("") @@ -239,18 +224,18 @@ def show_mkdir_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase mkdir [DIRECTORY] [OPTIONS]") - print(" OR: sbase mkdir [DIRECTORY] [OPTIONS]") + print(" seleniumbase mkdir [DIRECTORY] [OPTIONS]") + print(" OR: sbase mkdir [DIRECTORY] [OPTIONS]") print(" Example:") - print(" sbase mkdir ui_tests") + print(" sbase mkdir ui_tests") print(" Options:") - print(" -b / --basic (Only config files. No tests added.)") + print(" -b / --basic (Only config files. No tests added.)") print(" Output:") - print(" Creates a new folder for running SBase scripts.") - print(" The new folder contains default config files,") - print(" sample tests for helping new users get started,") - print(" and Python boilerplates for setting up customized") - print(" test frameworks.") + print(" Creates a new folder for running SBase scripts.") + print(" The new folder contains default config files,") + print(" sample tests for helping new users get started,") + print(" and Python boilerplates for setting up customized") + print(" test frameworks.") print("") @@ -262,38 +247,38 @@ def show_mkfile_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase mkfile [FILE.py] [OPTIONS]") - print(" OR: sbase mkfile [FILE.py] [OPTIONS]") + print(" seleniumbase mkfile [FILE.py] [OPTIONS]") + print(" OR: sbase mkfile [FILE.py] [OPTIONS]") print(" Example:") - print(" sbase mkfile new_test.py") + print(" sbase mkfile new_test.py") print(" Options:") - print(" --uc (UC Mode boilerplate using SB context manager)") - print(" -b / --basic (Basic boilerplate / single-line test)") - print(" -r / --rec (Adds Pdb+ breakpoint for Recorder Mode)") - print(" --url=URL (Makes the test start on a specific page)") + print(" --uc (UC Mode boilerplate using SB context manager)") + print(" -b / --basic (Basic boilerplate / single-line test)") + print(" -r / --rec (Adds Pdb+ breakpoint for Recorder Mode)") + print(" --url=URL (Makes the test start on a specific page)") print(" Language Options:") - print(" --en / --English | --zh / --Chinese") - print(" --nl / --Dutch | --fr / --French") - print(" --it / --Italian | --ja / --Japanese") - print(" --ko / --Korean | --pt / --Portuguese") - print(" --ru / --Russian | --es / --Spanish") + print(" --en / --English | --zh / --Chinese") + print(" --nl / --Dutch | --fr / --French") + print(" --it / --Italian | --ja / --Japanese") + print(" --ko / --Korean | --pt / --Portuguese") + print(" --ru / --Russian | --es / --Spanish") print(" Syntax Formats:") - print(" --bc / --basecase (BaseCase class inheritance)") - print(" --pf / --pytest-fixture (sb pytest fixture)") - print(" --cf / --class-fixture (class + sb pytest fixture)") - print(" --cm / --context-manager (SB context manager)") - print(" --dc / --driver-context (DriverContext manager)") - print(" --dm / --driver-manager (Driver manager)") + print(" --bc / --basecase (BaseCase class inheritance)") + print(" --pf / --pytest-fixture (sb pytest fixture)") + print(" --cf / --class-fixture (class + sb pytest fixture)") + print(" --cm / --context-manager (SB context manager)") + print(" --dc / --driver-context (DriverContext manager)") + print(" --dm / --driver-manager (Driver manager)") print(" Output:") - print(" Creates a new SBase test file with boilerplate code.") - print(" If the file already exists, an error is raised.") - print(" By default, uses English with BaseCase inheritance,") - print(" and creates a boilerplate with common SeleniumBase") - print(' methods: "open", "type", "click", "assert_element",') - print(' and "assert_text". If using the basic boilerplate') - print(' option, only the "open" method is included. Only the') - print(" BaseCase format supports Languages or Recorder Mode.") - print(" UC Mode automatically uses English with SB() format.") + print(" Creates a new SBase test file with boilerplate code.") + print(" If the file already exists, an error is raised.") + print(" By default, uses English with BaseCase inheritance,") + print(" and creates a boilerplate with common SeleniumBase") + print(' methods: "open", "type", "click", "assert_element",') + print(' and "assert_text". If using the basic boilerplate') + print(' option, only the "open" method is included. Only the') + print(" BaseCase format supports Languages or Recorder Mode.") + print(" UC Mode automatically uses English with SB() format.") print("") @@ -305,22 +290,22 @@ def show_mkrec_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase mkrec [FILE.py] [OPTIONS]") - print(" OR: sbase mkrec [FILE.py] [OPTIONS]") + print(" seleniumbase mkrec [FILE.py] [OPTIONS]") + print(" OR: sbase mkrec [FILE.py] [OPTIONS]") print(" Examples:") - print(" sbase mkrec new_test.py") - print(" sbase mkrec new_test.py --url=wikipedia.org") + print(" sbase mkrec new_test.py") + print(" sbase mkrec new_test.py --url=wikipedia.org") print(" Options:") - print(" --url=URL (Sets the initial start page URL.)") - print(" --edge (Use Edge browser instead of Chrome.)") - print(" --gui / --headed (Use headed mode on Linux.)") - print(" --uc / --undetected (Use undetectable mode.)") - print(" --ee (Use SHIFT + ESC to end the recording.)") - print(" --overwrite (Overwrite file when it exists.)") - print(" --behave (Also output Behave/Gherkin files.)") + print(" --url=URL (Sets the initial start page URL.)") + print(" --edge (Use Edge browser instead of Chrome.)") + print(" --gui / --headed (Use headed mode on Linux.)") + print(" --uc / --undetected (Use undetectable mode.)") + print(" --ee (Use SHIFT + ESC to end the recording.)") + print(" --overwrite (Overwrite file when it exists.)") + print(" --behave (Also output Behave/Gherkin files.)") print(" Output:") - print(" Creates a new SeleniumBase test using the Recorder.") - print(" If the filename already exists, an error is raised.") + print(" Creates a new SeleniumBase test using the Recorder.") + print(" If the filename already exists, an error is raised.") print("") @@ -332,22 +317,22 @@ def show_codegen_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase codegen [FILE.py] [OPTIONS]") - print(" OR: sbase codegen [FILE.py] [OPTIONS]") + print(" seleniumbase codegen [FILE.py] [OPTIONS]") + print(" OR: sbase codegen [FILE.py] [OPTIONS]") print(" Examples:") - print(" sbase codegen new_test.py") - print(" sbase codegen new_test.py --url=wikipedia.org") + print(" sbase codegen new_test.py") + print(" sbase codegen new_test.py --url=wikipedia.org") print(" Options:") - print(" --url=URL (Sets the initial start page URL.)") - print(" --edge (Use Edge browser instead of Chrome.)") - print(" --gui / --headed (Use headed mode on Linux.)") - print(" --uc / --undetected (Use undetectable mode.)") - print(" --ee (Use SHIFT + ESC to end the recording.)") - print(" --overwrite (Overwrite file when it exists.)") - print(" --behave (Also output Behave/Gherkin files.)") + print(" --url=URL (Sets the initial start page URL.)") + print(" --edge (Use Edge browser instead of Chrome.)") + print(" --gui / --headed (Use headed mode on Linux.)") + print(" --uc / --undetected (Use undetectable mode.)") + print(" --ee (Use SHIFT + ESC to end the recording.)") + print(" --overwrite (Overwrite file when it exists.)") + print(" --behave (Also output Behave/Gherkin files.)") print(" Output:") - print(" Creates a new SeleniumBase test using the Recorder.") - print(" If the filename already exists, an error is raised.") + print(" Creates a new SeleniumBase test using the Recorder.") + print(" If the filename already exists, an error is raised.") print("") @@ -359,13 +344,13 @@ def show_recorder_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase recorder [OPTIONS]") - print(" OR: sbase recorder [OPTIONS]") + print(" seleniumbase recorder [OPTIONS]") + print(" OR: sbase recorder [OPTIONS]") print(" Options:") - print(" --uc / --undetected (Use undetectable mode.)") - print(" --behave (Also output Behave/Gherkin files.)") + print(" --uc / --undetected (Use undetectable mode.)") + print(" --behave (Also output Behave/Gherkin files.)") print(" Output:") - print(" Launches the SeleniumBase Recorder Desktop App.") + print(" Launches the SeleniumBase Recorder Desktop App.") print("") @@ -377,22 +362,22 @@ def show_mkpres_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase mkpres [FILE.py] [LANG]") - print(" OR: sbase mkpres [FILE.py] [LANG]") + print(" seleniumbase mkpres [FILE.py] [LANG]") + print(" OR: sbase mkpres [FILE.py] [LANG]") print(" Example:") - print(" sbase mkpres new_presentation.py --en") + print(" sbase mkpres new_presentation.py --en") print(" Language Options:") - print(" --en / --English | --zh / --Chinese") - print(" --nl / --Dutch | --fr / --French") - print(" --it / --Italian | --ja / --Japanese") - print(" --ko / --Korean | --pt / --Portuguese") - print(" --ru / --Russian | --es / --Spanish") + print(" --en / --English | --zh / --Chinese") + print(" --nl / --Dutch | --fr / --French") + print(" --it / --Italian | --ja / --Japanese") + print(" --ko / --Korean | --pt / --Portuguese") + print(" --ru / --Russian | --es / --Spanish") print(" Output:") - print(" Creates a new presentation with 3 example slides.") - print(" If the file already exists, an error is raised.") - print(" By default, the slides are written in English,") - print(' and use "serif" theme with "slide" transition.') - print(" The slides can be used as a basic boilerplate.") + print(" Creates a new presentation with 3 example slides.") + print(" If the file already exists, an error is raised.") + print(" By default, the slides are written in English,") + print(' and use "serif" theme with "slide" transition.') + print(" The slides can be used as a basic boilerplate.") print("") @@ -404,22 +389,22 @@ def show_mkchart_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase mkchart [FILE.py] [LANG]") - print(" OR: sbase mkchart [FILE.py] [LANG]") + print(" seleniumbase mkchart [FILE.py] [LANG]") + print(" OR: sbase mkchart [FILE.py] [LANG]") print(" Example:") - print(" sbase mkchart new_chart.py --en") + print(" sbase mkchart new_chart.py --en") print(" Language Options:") - print(" --en / --English | --zh / --Chinese") - print(" --nl / --Dutch | --fr / --French") - print(" --it / --Italian | --ja / --Japanese") - print(" --ko / --Korean | --pt / --Portuguese") - print(" --ru / --Russian | --es / --Spanish") + print(" --en / --English | --zh / --Chinese") + print(" --nl / --Dutch | --fr / --French") + print(" --it / --Italian | --ja / --Japanese") + print(" --ko / --Korean | --pt / --Portuguese") + print(" --ru / --Russian | --es / --Spanish") print(" Output:") - print(" Creates a new SeleniumBase chart presentation.") - print(" If the file already exists, an error is raised.") - print(" By default, the slides are written in English,") - print(' and use a "sky" theme with "slide" transition.') - print(" The chart can be used as a basic boilerplate.") + print(" Creates a new SeleniumBase chart presentation.") + print(" If the file already exists, an error is raised.") + print(" By default, the slides are written in English,") + print(' and use a "sky" theme with "slide" transition.') + print(" The chart can be used as a basic boilerplate.") print("") @@ -431,13 +416,13 @@ def show_convert_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase convert [WEBDRIVER_UNITTEST_FILE.py]") - print(" OR: sbase convert [WEBDRIVER_UNITTEST_FILE.py]") + print(" seleniumbase convert [WEBDRIVER_UNITTEST_FILE.py]") + print(" OR: sbase convert [WEBDRIVER_UNITTEST_FILE.py]") print(" Output:") - print(" Converts a Selenium IDE exported WebDriver unittest") - print(" file into a SeleniumBase file. Adds _SB to the new") - print(" file name while keeping the original file intact.") - print(" (Works with Katalon Recorder Selenium scripts.)") + print(" Converts a Selenium IDE exported WebDriver unittest") + print(" file into a SeleniumBase file. Adds _SB to the new") + print(" file name while keeping the original file intact.") + print(" (Works with Katalon Recorder Selenium scripts.)") print("") @@ -449,13 +434,13 @@ def show_print_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase print [FILE] [OPTIONS]") - print(" OR: sbase print [FILE] [OPTIONS]") + print(" seleniumbase print [FILE] [OPTIONS]") + print(" OR: sbase print [FILE] [OPTIONS]") print(" Options:") - print(" -n (Add line Numbers to the rows)") + print(" -n (Add line Numbers to the rows)") print(" Output:") - print(" Prints the code/text of any file") - print(" with syntax-highlighting.") + print(" Prints the code/text of any file") + print(" with syntax-highlighting.") print("") @@ -467,30 +452,30 @@ def show_translate_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase translate [SB_FILE.py] [LANG] [ACTION]") - print(" OR: sbase translate [SB_FILE.py] [LANG] [ACTION]") + print(" seleniumbase translate [SB_FILE.py] [LANG] [ACTION]") + print(" OR: sbase translate [SB_FILE.py] [LANG] [ACTION]") print(" Languages:") - print(" --en / --English | --zh / --Chinese") - print(" --nl / --Dutch | --fr / --French") - print(" --it / --Italian | --ja / --Japanese") - print(" --ko / --Korean | --pt / --Portuguese") - print(" --ru / --Russian | --es / --Spanish") + print(" --en / --English | --zh / --Chinese") + print(" --nl / --Dutch | --fr / --French") + print(" --it / --Italian | --ja / --Japanese") + print(" --ko / --Korean | --pt / --Portuguese") + print(" --ru / --Russian | --es / --Spanish") print(" Actions:") - print(" -p / --print (Print translation output to the screen)") - print(" -o / --overwrite (Overwrite the file being translated)") - print(" -c / --copy (Copy the translation to a new .py file)") + print(" -p / --print (Print translation output to the screen)") + print(" -o / --overwrite (Overwrite the file being translated)") + print(" -c / --copy (Copy the translation to a new .py file)") print(" Options:") - print(" -n (include line Numbers when using the Print action)") + print(" -n (include line Numbers when using the Print action)") print(" Output:") - print(" Translates a SeleniumBase Python file into the language") - print(' specified. Method calls and "import" lines get swapped.') - print(" Both a language and an action must be specified.") - print(' The "-p" action can be paired with one other action.') - print(' When running with "-c" (or "--copy"), the new file name') - print(" will be the original name appended with an underscore") - print(" plus the 2-letter language code of the new language.") - print(' (Example: Translating "test_1.py" into Japanese with') - print(' "-c" will create a new file called "test_1_ja.py".)') + print(" Translates a SeleniumBase Python file into the language") + print(' specified. Method calls and "import" lines get swapped.') + print(" Both a language and an action must be specified.") + print(' The "-p" action can be paired with one other action.') + print(' When running with "-c" (or "--copy"), the new file name') + print(" will be the original name appended with an underscore") + print(" plus the 2-letter language code of the new language.") + print(' (Example: Translating "test_1.py" into Japanese with') + print(' "-c" will create a new file called "test_1_ja.py".)') print("") @@ -502,12 +487,12 @@ def show_extract_objects_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase extract-objects [SB_FILE.py]") - print(" OR: sbase extract-objects [SB_FILE.py]") + print(" seleniumbase extract-objects [SB_FILE.py]") + print(" OR: sbase extract-objects [SB_FILE.py]") print(" Output:") - print(" Creates page objects based on selectors found in a") - print(" seleniumbase Python file and saves those objects to the") - print(' "page_objects.py" file in the same folder as the tests.') + print(" Creates page objects based on selectors found in a") + print(" seleniumbase Python file and saves those objects to the") + print(' "page_objects.py" file in the same folder as the tests.') print("") @@ -519,15 +504,15 @@ def show_inject_objects_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase inject-objects [SB_FILE.py] [OPTIONS]") - print(" OR: sbase inject-objects [SB_FILE.py] [OPTIONS]") + print(" seleniumbase inject-objects [SB_FILE.py] [OPTIONS]") + print(" OR: sbase inject-objects [SB_FILE.py] [OPTIONS]") print(" Options:") - print(" -c, --comments (Add object selectors to the comments.)") - print(" (Default: No added comments.)") + print(" -c, --comments (Add object selectors to the comments.)") + print(" (Default: No added comments.)") print(" Output:") - print(' Takes the page objects found in the "page_objects.py"') - print(" file and uses those to replace matching selectors in") - print(" the selected seleniumbase Python file.") + print(' Takes the page objects found in the "page_objects.py"') + print(" file and uses those to replace matching selectors in") + print(" the selected seleniumbase Python file.") print("") @@ -539,18 +524,18 @@ def show_objectify_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase objectify [SB_FILE.py] [OPTIONS]") - print(" OR: sbase objectify [SB_FILE.py] [OPTIONS]") + print(" seleniumbase objectify [SB_FILE.py] [OPTIONS]") + print(" OR: sbase objectify [SB_FILE.py] [OPTIONS]") print(" Options:") - print(" -c, --comments (Add object selectors to the comments.)") - print(" (Default: No added comments.)") + print(" -c, --comments (Add object selectors to the comments.)") + print(" (Default: No added comments.)") print(" Output:") - print(" A modified version of the file where the selectors") - print(" have been replaced with variable names defined in") - print(' "page_objects.py", supporting the Page Object Pattern.') + print(" A modified version of the file where the selectors") + print(" have been replaced with variable names defined in") + print(' "page_objects.py", supporting the Page Object Pattern.') print("") - print(' (seleniumbase "objectify" has the same outcome as') - print(' combining "extract-objects" with "inject-objects")') + print(' (seleniumbase "objectify" has the same outcome as') + print(' combining "extract-objects" with "inject-objects")') print("") @@ -562,16 +547,16 @@ def show_revert_objects_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase revert-objects [SB_FILE.py] [OPTIONS]") - print(" OR: sbase revert-objects [SB_FILE.py] [OPTIONS]") + print(" seleniumbase revert-objects [SB_FILE.py] [OPTIONS]") + print(" OR: sbase revert-objects [SB_FILE.py] [OPTIONS]") print(" Options:") - print(" -c, --comments (Keep existing comments for the lines.)") - print(" (Default: No comments are kept.)") + print(" -c, --comments (Keep existing comments for the lines.)") + print(" (Default: No comments are kept.)") print(" Output:") - print(' Reverts the changes made by "seleniumbase objectify" or') - print(' "seleniumbase inject-objects" when run against a') - print(" seleniumbase Python file. Objects will get replaced by") - print(' selectors stored in the "page_objects.py" file.') + print(' Reverts the changes made by "seleniumbase objectify" or') + print(' "seleniumbase inject-objects" when run against a') + print(" seleniumbase Python file. Objects will get replaced by") + print(' selectors stored in the "page_objects.py" file.') print("") @@ -583,12 +568,12 @@ def show_encrypt_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase encrypt || seleniumbase obfuscate") - print(" --OR--") - print(" sbase encrypt || sbase obfuscate") + print(" seleniumbase encrypt || seleniumbase obfuscate") + print(" --OR--") + print(" sbase encrypt || sbase obfuscate") print(" Output:") - print(" Runs the password encryption/obfuscation tool.") - print(" (Where you can enter a password to encrypt/obfuscate.)") + print(" Runs the password encryption/obfuscation tool.") + print(" (Where you can enter a password to encrypt/obfuscate.)") print("") @@ -600,12 +585,12 @@ def show_decrypt_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase decrypt || seleniumbase unobfuscate") - print(" --OR--") - print(" sbase decrypt || sbase unobfuscate") + print(" seleniumbase decrypt || seleniumbase unobfuscate") + print(" --OR--") + print(" sbase decrypt || sbase unobfuscate") print(" Output:") - print(" Runs the password decryption/unobfuscation tool.") - print(" (Where you can enter an encrypted password to decrypt.)") + print(" Runs the password decryption/unobfuscation tool.") + print(" (Where you can enter an encrypted password to decrypt.)") print("") @@ -617,11 +602,11 @@ def show_download_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase download server") - print(" OR: sbase download server") + print(" seleniumbase download server") + print(" OR: sbase download server") print(" Output:") - print(" Downloads the Selenium Standalone Server.") - print(" (Server is required for using your own Selenium Grid.)") + print(" Downloads the Selenium Standalone Server.") + print(" (Server is required for using your own Selenium Grid.)") print("") @@ -633,22 +618,22 @@ def show_grid_hub_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase grid-hub {start|stop|restart} [OPTIONS]") - print(" OR: sbase grid-hub {start|stop|restart} [OPTIONS]") + print(" seleniumbase grid-hub {start|stop|restart} [OPTIONS]") + print(" OR: sbase grid-hub {start|stop|restart} [OPTIONS]") print(" Options:") - print(" -v, --verbose (Increase verbosity of logging output.)") - print(" (Default: Quiet logging / not verbose.)") - print(" --timeout=TIMEOUT (Close idle browser after TIMEOUT.)") - print(" (The default TIMEOUT: 230 seconds.)") - print(" (Use --timeout=0 to skip timeouts.)") + print(" -v, --verbose (Increase verbosity of logging output.)") + print(" (Default: Quiet logging / not verbose.)") + print(" --timeout=TIMEOUT (Close idle browser after TIMEOUT.)") + print(" (The default TIMEOUT: 230 seconds.)") + print(" (Use --timeout=0 to skip timeouts.)") print(" Example:") - print(" seleniumbase grid-hub start") + print(" seleniumbase grid-hub start") print(" Output:") - print(" Controls the Selenium Grid Hub Server, which allows") - print(" for running tests on multiple machines in parallel") - print(" to speed up test runs and reduce the total time") - print(" of test suite execution.") - print(' You can "start" or "stop" the Grid Hub server.') + print(" Controls the Selenium Grid Hub Server, which allows") + print(" for running tests on multiple machines in parallel") + print(" to speed up test runs and reduce the total time") + print(" of test suite execution.") + print(' You can "start" or "stop" the Grid Hub server.') print("") @@ -660,19 +645,19 @@ def show_grid_node_usage(): print(sc) print("") print(" Usage:") - print(" seleniumbase grid-node {start|stop|restart} [OPTIONS]") - print(" OR: sbase grid-node {start|stop|restart} [OPTIONS]") + print(" seleniumbase grid-node {start|stop|restart} [OPTIONS]") + print(" OR: sbase grid-node {start|stop|restart} [OPTIONS]") print(" Options:") - print(" --hub=[HOST/IP] (The Grid Hub Hostname / IP Address.)") - print(" (Default: 127.0.0.1 if not set.)") - print(" -v, --verbose (Increase verbosity of logging output.)") - print(" (Default: Quiet logging / Not verbose.)") + print(" --hub=[HOST/IP] (The Grid Hub Hostname / IP Address.)") + print(" (Default: 127.0.0.1 if not set.)") + print(" -v, --verbose (Increase verbosity of logging output.)") + print(" (Default: Quiet logging / Not verbose.)") print(" Example:") - print(" seleniumbase grid-node start --hub=127.0.0.1") + print(" seleniumbase grid-node start --hub=127.0.0.1") print(" Output:") - print(" Controls the Selenium Grid node, which serves as a") - print(" worker machine for your Selenium Grid Hub server.") - print(' You can "start" or "stop" the Grid node.') + print(" Controls the Selenium Grid node, which serves as a") + print(" worker machine for your Selenium Grid Hub server.") + print(' You can "start" or "stop" the Grid node.') print("") @@ -799,16 +784,16 @@ def show_options(): line = '(Some options are Chromium-specific, e.g. "--guest --mobile")' print(line) op = "\n" - op += '--browser=BROWSER (Choice of web browser. Default is "chrome".)\n' - op += "--edge / --firefox / --safari (Shortcut for browser selection.)\n" - op += "--headless (Run tests headlessly. Default setting on Linux OS.)\n" - op += "--demo (Slow down and visually see test actions as they occur.)\n" - op += "--slow (Slow down the automation. Faster than using Demo Mode.)\n" + op += '--browser=BROWSER (Choice of web browser. Default is "chrome")\n' + op += "--edge / --firefox / --safari (Shortcut for browser selection)\n" + op += "--headless (Run tests headlessly. Default setting on Linux OS)\n" + op += "--demo (Slow down and visually see test actions as they occur)\n" + op += "--slow (Slow down the automation. Faster than using Demo Mode)\n" op += "--rs / --reuse-session (Reuse browser session between tests.)\n" op += "--reuse-class-session / --rcs (RS, but for class tests only.)\n" op += "--crumbs (Clear all cookies between tests reusing a session.)\n" - op += "--maximize (Start tests with the web browser window maximized.)\n" - op += "--dashboard (Enable SeleniumBase's Dashboard at dashboard.html)\n" + op += "--maximize (Start tests with the browser window maximized)\n" + op += "--dashboard (Enable SeleniumBase Dashboard at dashboard.html)\n" op += "--incognito (Enable Chromium's Incognito Mode.)\n" op += "--guest (Enable Chromium's Guest Mode.)\n" op += "--dark (Enable Chromium's Dark Mode.)\n" @@ -820,15 +805,15 @@ def show_options(): op += "--collect-only / --co (Only show discovered tests. No run.)\n" op += "--co -q (Only show full names of discovered tests. No run.)\n" op += "-x (Stop running tests after the first failure is reached.)\n" - op += "--pdb (Enter the Post Mortem Debug Mode after any test fails.)\n" - op += "--trace (Enter Debug Mode immediately after starting any test.)\n" - op += " | Debug Mode Commands >>> help / h: List all commands. |\n" - op += " | n: Next line of method. s: Step through. c: Continue. |\n" - op += " | return / r: Run until method returns. j: Jump to line. |\n" - op += " | where / w: Show stack spot. u: Up stack. d: Down stack. |\n" - op += " | longlist / ll: See code. dir(): List namespace objects. |\n" + op += "--pdb (Enter Post Mortem Debug Mode after any test fails.)\n" + op += "--trace (Enter Debug Mode immediately after starting tests.)\n" + op += " | Debug Mode Commands >>> help / h: List all commands. |\n" + op += " | n: Next line of method. s: Step into. c: Continue. |\n" + op += " | where / w: Show stack spot. u: Up stack. d: Down stack. |\n" + op += " | return / r: Run until method returns. j: Jump to line. |\n" + op += " | longlist / ll: See code. dir(): List namespace objects. |\n" op += "--help / -h (Display list of all available pytest options.)\n" - op += "--ftrace / --final-trace (Enter Debug Mode after any test.)\n" + op += "--ftrace / --final-trace (Enter Debug Mode after tests end.)\n" op += "--recorder / --rec (Save browser actions as Python scripts.)\n" op += "--rec-behave / --rec-gherkin (Save actions as Gherkin code.)\n" op += "--rec-print (Display recorded scripts when they are created.)\n" @@ -841,14 +826,14 @@ def show_options(): op += '--metrics=STRING (Set mobile "CSSWidth,CSSHeight,PixelRatio".)\n' op += "--ad-block (Block certain types of iframe ads from appearing.)\n" op += "--settings-file=FILE (Override default SeleniumBase settings.)\n" - op += '--env=ENV (Set the test env. Access with "self.env" in tests.)\n' - op += '--data=DATA (Extra test data. Access with "self.data" in tests.)\n' - op += "--disable-csp (Disable the Content Security Policy of websites.)\n" - op += "--remote-debug (Sync to Ch-R-Debugger chrome://inspect/#devices)\n" + op += '--env=ENV (Set the test env. Use "self.env" to access.)\n' + op += '--data=DATA (Extra test data. Use "self.data" to access.)\n' + op += "--disable-csp (Disable the Content Security Policy of sites.)\n" + op += "--remote-debug (Sync to Ch_Debugger chrome://inspect/#devices)\n" op += "--server=SERVER (The Selenium Grid server/IP used for tests.)\n" op += "--port=PORT (The Selenium Grid port used by the test server.)\n" - op += "--proxy=SERVER:PORT (Connect to a proxy server:port for tests.)\n" - op += "--proxy=USER:PASS@SERVER:PORT (Use authenticated proxy server.)\n" + op += "--proxy=SERVER:PORT (Connect to a proxy server:port for tests)\n" + op += "--proxy=USER:PASS@SERVER:PORT (Use authenticated proxy server)\n" op += cr op = op.replace("\n-", "\n" + c1 + "-").replace(" (", cr + " (") op = op.replace(" / -", cr + " / " + c1 + "-") @@ -858,7 +843,8 @@ def show_options(): op = op.replace("Debug Mode Commands", c5 + "Debug Mode Commands" + c3) op = op.replace(">>>", c4 + ">>>" + c3) print(op) - line = "For the full list of " + c2 + "command-line options" + cr + line = "To view all " + c3 + "pytest" + cr + line += " " + c2 + "command-line options" + cr line += ', type: "' + c3 + "pytest" + cr + " " + c1 + "--help" + cr + '".' print(line) print("") @@ -880,14 +866,14 @@ def show_behave_options(): line = '(Some options are Chromium-specific, e.g. "-D guest -D mobile")' print(line) op = "\n" - op += '-D browser=BROWSER (The web browser to use. Default is "chrome")\n' + op += '-D browser=BROWSER (Choice of web browser. Default is "chrome")\n' op += "-D headless (Run tests headlessly. Default mode on Linux OS.)\n" - op += "-D demo (Slow down and visually see test actions as they occur.)\n" - op += "-D slow (Slow down the automation. Faster than using Demo Mode.)\n" + op += "-D demo (Slow down and visually see test actions as they occur)\n" + op += "-D slow (Slow down the automation. Faster than using Demo Mode)\n" op += "-D reuse-session / -D rs (Reuse browser session between tests.)\n" op += "-D crumbs (Clear all cookies between tests reusing a session.)\n" - op += "-D maximize (Start tests with the web browser window maximized.)\n" - op += "-D dashboard (Enable SeleniumBase's Dashboard at dashboard.html)\n" + op += "-D maximize (Start tests with the web browser window maximized)\n" + op += "-D dashboard (Enable SeleniumBase Dashboard at dashboard.html)\n" op += "-D incognito (Enable Chromium's Incognito Mode.)\n" op += "-D guest (Enable Chromium's Guest Mode.)\n" op += "-D dark (Enable Chromium's Dark Mode.)\n" @@ -896,11 +882,11 @@ def show_behave_options(): op += "--dry-run / -d (Dry run. Only show discovered tests.)\n" op += "--stop (Stop running tests after the first failure is reached.)\n" op += "-D pdb (Enter the Post Mortem Debug Mode after any test fails.)\n" - op += " | Debug Mode Commands >>> help / h: List all commands. |\n" - op += " | n: Next line of method. s: Step through. c: Continue. |\n" - op += " | return / r: Run until method returns. j: Jump to line. |\n" - op += " | where / w: Show stack spot. u: Up stack. d: Down stack. |\n" - op += " | longlist / ll: See code. dir(): List namespace objects. |\n" + op += " | Debug Mode Commands >>> help / h: List all commands. |\n" + op += " | n: Next line of method. s: Step through. c: Continue. |\n" + op += " | return / r: Run until method returns. j: Jump to line. |\n" + op += " | where / w: Show stack spot. u: Up stack. d: Down stack. |\n" + op += " | longlist / ll: See code. dir(): List namespace objects. |\n" op += "-D recorder (Record browser actions to generate test scripts.)\n" op += "-D rec-print (Display recorded scripts when they are created.)\n" op += "-D save-screenshot (Save a screenshot at the end of each test.)\n" @@ -912,14 +898,14 @@ def show_behave_options(): op += '-D metrics=STRING (Set mobile "CSSWidth,CSSHeight,PixelRatio".)\n' op += "-D ad-block (Block some types of display ads after page loads.)\n" op += "-D settings-file=FILE (Override default SeleniumBase settings.)\n" - op += '-D env=ENV (Set the test env. Access using "self.env" in tests.)\n' + op += '-D env=ENV (Set the test env. Access using "self.env" in tests)\n' op += '-D data=DATA (Extra test data. Access using "self.data".)\n' op += "-D disable-csp (Disable the Content Security Policy of sites.)\n" op += "-D remote-debug (Sync Ch-R-Debugger chrome://inspect/#devices)\n" op += "-D server=SERVER (The Selenium Grid server/IP used for tests.)\n" op += "-D port=PORT (The Selenium Grid port used by the test server.)\n" - op += "-D proxy=SERVER:PORT (Connect to a proxy server:port for tests.)\n" - op += "-D proxy=USER:PASS@SERVER:PORT (Use authenticated proxy server.)\n" + op += "-D proxy=SERVER:PORT (Connect to a proxy server:port for tests)\n" + op += "-D proxy=USER:PASS@SERVER:PORT (Use authenticated proxy server)\n" op += cr op = op.replace("\n-", "\n" + c1 + "-").replace(" (", cr + " (") op = op.replace(" / -", cr + " / " + c1 + "-") @@ -941,7 +927,7 @@ def show_detailed_help(): c6 = colorama.Back.CYAN cr = colorama.Style.RESET_ALL show_basic_usage() - print(c6 + " " + c2 + " Commands: " + c6 + " ") + print(c6 + " " + c2 + " Commands: " + c6 + " ") print(cr) show_install_usage() show_commander_usage() @@ -966,7 +952,10 @@ def show_detailed_help(): show_download_usage() show_grid_hub_usage() show_grid_node_usage() - print('* (Use "' + c3 + "pytest" + cr + '" for running tests) *\n') + print( + '* (Use "' + c3 + "pytest" + cr + '" or "' + c3 + '' + '' + "python" + cr + '" for running tests) *\n' + ) def main(): @@ -974,7 +963,7 @@ def main(): command_args = None num_args = len(sys.argv) if num_args == 1: - show_usage() + show_basic_usage() return elif num_args == 2: command = sys.argv[1] @@ -1202,7 +1191,7 @@ def main(): else: show_basic_usage() show_grid_node_usage() - elif command == "version" or command == "--version": + elif command == "version" or command == "--version" or command == "-v": if len(command_args) == 0: from seleniumbase.console_scripts import logo_helper @@ -1238,7 +1227,7 @@ def main(): "proxy.py", version=constants.ProxyPy.VER ) os.system("proxy %s" % " ".join(sys.argv[2:])) - elif command == "help" or command == "--help": + elif command == "help" or command == "--help" or command == "-h": if len(command_args) >= 1: if command_args[0] == "get": print("") @@ -1362,7 +1351,7 @@ def main(): return show_detailed_help() else: - show_usage() + show_basic_usage() c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA cr = colorama.Style.RESET_ALL diff --git a/seleniumbase/console_scripts/sb_behave_gui.py b/seleniumbase/console_scripts/sb_behave_gui.py index 6902c46ad39..66c14caf04b 100644 --- a/seleniumbase/console_scripts/sb_behave_gui.py +++ b/seleniumbase/console_scripts/sb_behave_gui.py @@ -38,13 +38,6 @@ def set_colors(use_colors): c6 = "" cr = "" if use_colors: - if ( - shared_utils.is_windows() - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c1 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX c2 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX diff --git a/seleniumbase/console_scripts/sb_caseplans.py b/seleniumbase/console_scripts/sb_caseplans.py index 63c5a3a0aae..9cc8a62a95e 100644 --- a/seleniumbase/console_scripts/sb_caseplans.py +++ b/seleniumbase/console_scripts/sb_caseplans.py @@ -42,13 +42,6 @@ def set_colors(use_colors): c5 = "" cr = "" if use_colors: - if ( - shared_utils.is_windows() - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c1 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX c2 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX diff --git a/seleniumbase/console_scripts/sb_commander.py b/seleniumbase/console_scripts/sb_commander.py index a5a15b8d434..9219efef62f 100644 --- a/seleniumbase/console_scripts/sb_commander.py +++ b/seleniumbase/console_scripts/sb_commander.py @@ -42,13 +42,6 @@ def set_colors(use_colors): c5 = "" cr = "" if use_colors: - if ( - shared_utils.is_windows() - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c1 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX c2 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX diff --git a/seleniumbase/console_scripts/sb_install.py b/seleniumbase/console_scripts/sb_install.py index 692490ae750..cc529097898 100644 --- a/seleniumbase/console_scripts/sb_install.py +++ b/seleniumbase/console_scripts/sb_install.py @@ -2,28 +2,28 @@ Downloads the specified webdriver to "seleniumbase/drivers/" Usage: - sbase get {chromedriver|geckodriver|edgedriver| - iedriver|uc_driver} [OPTIONS] + sbase get {chromedriver|geckodriver|edgedriver| + iedriver|uc_driver} [OPTIONS] Options: - VERSION Specify the version. - Tries to detect the needed version. - If using chromedriver or edgedriver, - you can use the major version integer. - -p OR --path Also copy the driver to /usr/local/bin + VERSION Specify the version. + Tries to detect the needed version. + If using chromedriver or edgedriver, + you can use the major version integer. + -p OR --path Also copy the driver to /usr/local/bin Examples: - sbase get chromedriver - sbase get geckodriver - sbase get edgedriver - sbase get chromedriver 114 - sbase get chromedriver 114.0.5735.90 - sbase get chromedriver stable - sbase get chromedriver beta - sbase get chromedriver -p + sbase get chromedriver + sbase get geckodriver + sbase get edgedriver + sbase get chromedriver 114 + sbase get chromedriver 114.0.5735.90 + sbase get chromedriver stable + sbase get chromedriver beta + sbase get chromedriver -p Output: - Downloads the webdriver to seleniumbase/drivers/ - (chromedriver is required for Chrome automation) - (geckodriver is required for Firefox automation) - (edgedriver is required for MS__Edge automation) + Downloads the webdriver to seleniumbase/drivers/ + (chromedriver is required for Chrome automation) + (geckodriver is required for Firefox automation) + (edgedriver is required for MS__Edge automation) """ import colorama import logging @@ -57,32 +57,33 @@ def invalid_run_command(): exp = " ** get / install **\n\n" exp += " Usage:\n" - exp += " seleniumbase install [DRIVER] [OPTIONS]\n" - exp += " OR sbase install [DRIVER] [OPTIONS]\n" - exp += " OR seleniumbase get [DRIVER] [OPTIONS]\n" - exp += " OR sbase get [DRIVER] [OPTIONS]\n" - exp += " (Drivers: chromedriver, geckodriver, edgedriver,\n" - exp += " iedriver, uc_driver)\n" + exp += " seleniumbase install [DRIVER_NAME] [OPTIONS]\n" + exp += " OR sbase install [DRIVER_NAME] [OPTIONS]\n" + exp += " OR seleniumbase get [DRIVER_NAME] [OPTIONS]\n" + exp += " OR sbase get [DRIVER_NAME] [OPTIONS]\n" + exp += " (Drivers: chromedriver, geckodriver,\n" + exp += " edgedriver, iedriver, uc_driver)\n" exp += " Options:\n" - exp += " VERSION Specify the version.\n" - exp += " Tries to detect the needed version.\n" - exp += " If using chromedriver or edgedriver,\n" - exp += " you can use the major version integer.\n" - exp += " -p OR --path Also copy the driver to /usr/local/bin\n" + exp += " VERSION Specify the version.\n" + exp += " Tries to detect the needed version.\n" + exp += " If using chromedriver or edgedriver,\n" + exp += " you can use the major version integer.\n" + exp += "\n" + exp += " -p OR --path Also copy the driver to /usr/local/bin\n" exp += " Examples:\n" - exp += " sbase get chromedriver\n" - exp += " sbase get geckodriver\n" - exp += " sbase get edgedriver\n" - exp += " sbase get chromedriver 114\n" - exp += " sbase get chromedriver 114.0.5735.90\n" - exp += " sbase get chromedriver stable\n" - exp += " sbase get chromedriver beta\n" - exp += " sbase get chromedriver -p\n" + exp += " sbase get chromedriver\n" + exp += " sbase get geckodriver\n" + exp += " sbase get edgedriver\n" + exp += " sbase get chromedriver 114\n" + exp += " sbase get chromedriver 114.0.5735.90\n" + exp += " sbase get chromedriver stable\n" + exp += " sbase get chromedriver beta\n" + exp += " sbase get chromedriver -p\n" exp += " Output:\n" - exp += " Downloads the webdriver to seleniumbase/drivers/\n" - exp += " (chromedriver is required for Chrome automation)\n" - exp += " (geckodriver is required for Firefox automation)\n" - exp += " (edgedriver is required for MS__Edge automation)\n" + exp += " Downloads the webdriver to seleniumbase/drivers/\n" + exp += " (chromedriver is required for Chrome automation)\n" + exp += " (geckodriver is required for Firefox automation)\n" + exp += " (edgedriver is required for MS__Edge automation)\n" print("") raise Exception("%s\n\n%s" % (constants.Warnings.INVALID_RUN_COMMAND, exp)) @@ -293,10 +294,6 @@ def main(override=None, intel_for_uc=None, force_uc=None): use_version = "" new_file = "" f_name = "" - if IS_WINDOWS and hasattr(colorama, "just_fix_windows_console"): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX @@ -944,7 +941,10 @@ def main(override=None, intel_for_uc=None, force_uc=None): f_name = "uc_driver" new_file = os.path.join(downloads_folder, str(f_name)) pr_file = c3 + new_file + cr - log_d("The file [%s] was saved to:\n%s\n" % (f_name, pr_file)) + d_folder = os.sep.join(pr_file.split(os.sep)[:-1]) + os.sep + d_file = pr_file.split(os.sep)[-1] + d_ff = c3 + d_folder + cr + "\n" + c3 + d_file + cr + log_d("The file [%s] was saved to:\n%s\n" % (f_name, d_ff)) log_d("Making [%s %s] executable ..." % (f_name, use_version)) make_executable(new_file) log_d( diff --git a/seleniumbase/console_scripts/sb_mkchart.py b/seleniumbase/console_scripts/sb_mkchart.py index 1af8e71c79f..d8af20f1b24 100644 --- a/seleniumbase/console_scripts/sb_mkchart.py +++ b/seleniumbase/console_scripts/sb_mkchart.py @@ -31,22 +31,22 @@ def invalid_run_command(msg=None): exp = " ** mkchart **\n\n" exp += " Usage:\n" - exp += " seleniumbase mkchart [FILE.py] [LANG]\n" - exp += " OR sbase mkchart [FILE.py] [LANG]\n" + exp += " seleniumbase mkchart [FILE.py] [LANG]\n" + exp += " OR sbase mkchart [FILE.py] [LANG]\n" exp += " Example:\n" - exp += " sbase mkchart new_chart.py --en\n" + exp += " sbase mkchart new_chart.py --en\n" exp += " Language Options:\n" - exp += " --en / --English | --zh / --Chinese\n" - exp += " --nl / --Dutch | --fr / --French\n" - exp += " --it / --Italian | --ja / --Japanese\n" - exp += " --ko / --Korean | --pt / --Portuguese\n" - exp += " --ru / --Russian | --es / --Spanish\n" + exp += " --en / --English | --zh / --Chinese\n" + exp += " --nl / --Dutch | --fr / --French\n" + exp += " --it / --Italian | --ja / --Japanese\n" + exp += " --ko / --Korean | --pt / --Portuguese\n" + exp += " --ru / --Russian | --es / --Spanish\n" exp += " Output:\n" - exp += " Creates a new SeleniumBase chart presentation.\n" - exp += " If the file already exists, an error is raised.\n" - exp += " By default, the slides are written in English,\n" - exp += ' and use a "sky" theme with "slide" transition.\n' - exp += " The chart can be used as a basic boilerplate.\n" + exp += " Creates a new SeleniumBase chart presentation.\n" + exp += " If the file already exists, an error is raised.\n" + exp += " By default, the slides are written in English,\n" + exp += ' and use a "sky" theme with "slide" transition.\n' + exp += " The chart can be used as a basic boilerplate.\n" if not msg: raise Exception("INVALID RUN COMMAND!\n\n%s" % exp) elif msg == "help": @@ -62,13 +62,6 @@ def main(): c7 = "" cr = "" if "linux" not in sys.platform: - if ( - "win32" in sys.platform - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA diff --git a/seleniumbase/console_scripts/sb_mkdir.py b/seleniumbase/console_scripts/sb_mkdir.py index 302b6caf8b4..7db1f6b2035 100644 --- a/seleniumbase/console_scripts/sb_mkdir.py +++ b/seleniumbase/console_scripts/sb_mkdir.py @@ -27,18 +27,18 @@ def invalid_run_command(msg=None): exp = " ** mkdir **\n\n" exp += " Usage:\n" - exp += " seleniumbase mkdir [DIRECTORY] [OPTIONS]\n" - exp += " OR sbase mkdir [DIRECTORY] [OPTIONS]\n" + exp += " seleniumbase mkdir [DIRECTORY] [OPTIONS]\n" + exp += " OR sbase mkdir [DIRECTORY] [OPTIONS]\n" exp += " Example:\n" - exp += " sbase mkdir ui_tests\n" + exp += " sbase mkdir ui_tests\n" exp += " Options:\n" - exp += " -b / --basic (Only config files. No tests added.)\n" + exp += " -b / --basic (Only config files. No tests added.)\n" exp += " Output:\n" - exp += " Creates a new folder for running SBase scripts.\n" - exp += " The new folder contains default config files,\n" - exp += " sample tests for helping new users get started,\n" - exp += " and Python boilerplates for setting up customized\n" - exp += " test frameworks.\n" + exp += " Creates a new folder for running SBase scripts.\n" + exp += " The new folder contains default config files,\n" + exp += " sample tests for helping new users get started,\n" + exp += " and Python boilerplates for setting up customized\n" + exp += " test frameworks.\n" if not msg: raise Exception("INVALID RUN COMMAND!\n\n%s" % exp) elif msg == "help": @@ -54,13 +54,6 @@ def main(): c7 = "" cr = "" if "linux" not in sys.platform: - if ( - "win32" in sys.platform - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA diff --git a/seleniumbase/console_scripts/sb_mkfile.py b/seleniumbase/console_scripts/sb_mkfile.py index 6abe7b3704b..c2e235fff96 100644 --- a/seleniumbase/console_scripts/sb_mkfile.py +++ b/seleniumbase/console_scripts/sb_mkfile.py @@ -49,38 +49,38 @@ def invalid_run_command(msg=None): exp = " ** mkfile **\n\n" exp += " Usage:\n" - exp += " seleniumbase mkfile [FILE.py] [OPTIONS]\n" - exp += " OR sbase mkfile [FILE.py] [OPTIONS]\n" + exp += " seleniumbase mkfile [FILE.py] [OPTIONS]\n" + exp += " OR sbase mkfile [FILE.py] [OPTIONS]\n" exp += " Example:\n" - exp += " sbase mkfile new_test.py\n" + exp += " sbase mkfile new_test.py\n" exp += " Options:\n" - exp += " --uc (UC Mode boilerplate using SB context manager)\n" - exp += " -b / --basic (Basic boilerplate / single-line test)\n" - exp += " -r / --rec (Adds Pdb+ breakpoint for Recorder Mode)\n" - exp += " --url=URL (Makes the test start on a specific page)\n" + exp += " --uc (UC Mode boilerplate using SB context manager)\n" + exp += " -b / --basic (Basic boilerplate / single-line test)\n" + exp += " -r / --rec (Adds Pdb+ breakpoint for Recorder Mode)\n" + exp += " --url=URL (Makes the test start on a specific page)\n" exp += " Language Options:\n" - exp += " --en / --English | --zh / --Chinese\n" - exp += " --nl / --Dutch | --fr / --French\n" - exp += " --it / --Italian | --ja / --Japanese\n" - exp += " --ko / --Korean | --pt / --Portuguese\n" - exp += " --ru / --Russian | --es / --Spanish\n" + exp += " --en / --English | --zh / --Chinese\n" + exp += " --nl / --Dutch | --fr / --French\n" + exp += " --it / --Italian | --ja / --Japanese\n" + exp += " --ko / --Korean | --pt / --Portuguese\n" + exp += " --ru / --Russian | --es / --Spanish\n" exp += " Syntax Formats:\n" - exp += " --bc / --basecase (BaseCase class inheritance)\n" - exp += " --pf / --pytest-fixture (sb pytest fixture)\n" - exp += " --cf / --class-fixture (class + sb pytest fixture)\n" - exp += " --cm / --context-manager (SB context manager)\n" - exp += " --dc / --driver-context (DriverContext manager)\n" - exp += " --dm / --driver-manager (Driver manager)\n" + exp += " --bc / --basecase (BaseCase class inheritance)\n" + exp += " --pf / --pytest-fixture (sb pytest fixture)\n" + exp += " --cf / --class-fixture (class + sb pytest fixture)\n" + exp += " --cm / --context-manager (SB context manager)\n" + exp += " --dc / --driver-context (DriverContext manager)\n" + exp += " --dm / --driver-manager (Driver manager)\n" exp += " Output:\n" - exp += " Creates a new SBase test file with boilerplate code.\n" - exp += " If the file already exists, an error is raised.\n" - exp += " By default, uses English with BaseCase inheritance,\n" - exp += " and creates a boilerplate with common SeleniumBase\n" - exp += ' methods: "open", "type", "click", "assert_element",\n' - exp += ' and "assert_text". If using the basic boilerplate\n' - exp += ' option, only the "open" method is included. Only the\n' - exp += " BaseCase format supports Languages or Recorder Mode.\n" - exp += " UC Mode automatically uses English with SB() format.\n" + exp += " Creates a new SBase test file with boilerplate code.\n" + exp += " If the file already exists, an error is raised.\n" + exp += " By default, uses English with BaseCase inheritance,\n" + exp += " and creates a boilerplate with common SeleniumBase\n" + exp += ' methods: "open", "type", "click", "assert_element",\n' + exp += ' and "assert_text". If using the basic boilerplate\n' + exp += ' option, only the "open" method is included. Only the\n' + exp += " BaseCase format supports Languages or Recorder Mode.\n" + exp += " UC Mode automatically uses English with SB() format.\n" if not msg: raise Exception("INVALID RUN COMMAND!\n\n%s" % exp) elif msg == "help": @@ -96,13 +96,6 @@ def main(): c7 = "" cr = "" if "linux" not in sys.platform: - if ( - "win32" in sys.platform - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA diff --git a/seleniumbase/console_scripts/sb_mkpres.py b/seleniumbase/console_scripts/sb_mkpres.py index d52b211d1fb..235bbfb0c96 100644 --- a/seleniumbase/console_scripts/sb_mkpres.py +++ b/seleniumbase/console_scripts/sb_mkpres.py @@ -31,22 +31,22 @@ def invalid_run_command(msg=None): exp = " ** mkpres **\n\n" exp += " Usage:\n" - exp += " seleniumbase mkpres [FILE.py] [LANG]\n" - exp += " OR sbase mkpres [FILE.py] [LANG]\n" + exp += " seleniumbase mkpres [FILE.py] [LANG]\n" + exp += " OR sbase mkpres [FILE.py] [LANG]\n" exp += " Example:\n" - exp += " sbase mkpres new_presentation.py --en\n" + exp += " sbase mkpres new_presentation.py --en\n" exp += " Language Options:\n" - exp += " --en / --English | --zh / --Chinese\n" - exp += " --nl / --Dutch | --fr / --French\n" - exp += " --it / --Italian | --ja / --Japanese\n" - exp += " --ko / --Korean | --pt / --Portuguese\n" - exp += " --ru / --Russian | --es / --Spanish\n" + exp += " --en / --English | --zh / --Chinese\n" + exp += " --nl / --Dutch | --fr / --French\n" + exp += " --it / --Italian | --ja / --Japanese\n" + exp += " --ko / --Korean | --pt / --Portuguese\n" + exp += " --ru / --Russian | --es / --Spanish\n" exp += " Output:\n" - exp += " Creates a new presentation with 3 example slides.\n" - exp += " If the file already exists, an error is raised.\n" - exp += " By default, the slides are written in English,\n" - exp += ' and use "serif" theme with "slide" transition.\n' - exp += " The slides can be used as a basic boilerplate.\n" + exp += " Creates a new presentation with 3 example slides.\n" + exp += " If the file already exists, an error is raised.\n" + exp += " By default, the slides are written in English,\n" + exp += ' and use "serif" theme with "slide" transition.\n' + exp += " The slides can be used as a basic boilerplate.\n" if not msg: raise Exception("INVALID RUN COMMAND!\n\n%s" % exp) elif msg == "help": @@ -62,13 +62,6 @@ def main(): c7 = "" cr = "" if "linux" not in sys.platform: - if ( - "win32" in sys.platform - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA diff --git a/seleniumbase/console_scripts/sb_mkrec.py b/seleniumbase/console_scripts/sb_mkrec.py index 65933894b74..99a448cad13 100644 --- a/seleniumbase/console_scripts/sb_mkrec.py +++ b/seleniumbase/console_scripts/sb_mkrec.py @@ -39,21 +39,21 @@ def invalid_run_command(msg=None): exp = " ** mkrec / record / codegen **\n\n" exp += " Usage:\n" - exp += " seleniumbase mkrec [FILE.py]\n" - exp += " OR: sbase mkrec [FILE.py]\n" + exp += " seleniumbase mkrec [FILE.py]\n" + exp += " OR: sbase mkrec [FILE.py]\n" exp += " Examples:\n" - exp += " sbase mkrec new_test.py\n" - exp += " sbase mkrec new_test.py --url=wikipedia.org\n" + exp += " sbase mkrec new_test.py\n" + exp += " sbase mkrec new_test.py --url=wikipedia.org\n" exp += " Options:\n" - exp += " --url=URL (Sets the initial start page URL.)\n" - exp += " --edge (Use Edge browser instead of Chrome.)\n" - exp += " --gui / --headed (Use headed mode on Linux.)\n" - exp += " --uc / --undetected (Use undetectable mode.)\n" - exp += " --overwrite (Overwrite file when it exists.)\n" - exp += " --behave (Also output Behave/Gherkin files.)\n" + exp += " --url=URL (Sets the initial start page URL.)\n" + exp += " --edge (Use Edge browser instead of Chrome.)\n" + exp += " --gui / --headed (Use headed mode on Linux.)\n" + exp += " --uc / --undetected (Use undetectable mode.)\n" + exp += " --overwrite (Overwrite file when it exists.)\n" + exp += " --behave (Also output Behave/Gherkin files.)\n" exp += " Output:\n" - exp += " Creates a new SeleniumBase test using the Recorder.\n" - exp += " If the filename already exists, an error is raised.\n" + exp += " Creates a new SeleniumBase test using the Recorder.\n" + exp += " If the filename already exists, an error is raised.\n" if not msg: raise Exception("INVALID RUN COMMAND!\n\n%s" % exp) elif msg == "help": @@ -71,13 +71,6 @@ def set_colors(use_colors): c7 = "" cr = "" if use_colors: - if ( - "win32" in sys.platform - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c1 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX c2 = colorama.Fore.LIGHTRED_EX + colorama.Back.LIGHTYELLOW_EX diff --git a/seleniumbase/console_scripts/sb_objectify.py b/seleniumbase/console_scripts/sb_objectify.py index 3ebb23a2533..0a3e880d7c9 100644 --- a/seleniumbase/console_scripts/sb_objectify.py +++ b/seleniumbase/console_scripts/sb_objectify.py @@ -2,11 +2,11 @@ Converts a SeleniumBase Python file into one that uses the Page Object Pattern. Usage: - seleniumbase objectify [SELENIUMBASE_PYTHON_FILE].py + seleniumbase objectify [SELENIUMBASE_PYTHON_FILE].py Output: - A modified version of the file where the selectors - have been replaced with variable names defined in - "page_objects.py", supporting the Page Object Pattern. + A modified version of the file where the selectors + have been replaced with variable names defined in + "page_objects.py", supporting the Page Object Pattern. """ import codecs import os @@ -35,57 +35,57 @@ def invalid_run_command(shell_command): def invalid_objectify_run_command(): exp = " ** objectify **\n\n" exp += " Usage:\n" - exp += " seleniumbase objectify [SELENIUMBASE_PYTHON_FILE]\n" + exp += " seleniumbase objectify [SELENIUMBASE_PYTHON_FILE]\n" exp += " Options:\n" - exp += " -c, --comments (Add object selectors to the comments.)\n" - exp += " (Default: No added comments.)\n" + exp += " -c, --comments (Add object selectors to the comments.)\n" + exp += " (Default: No added comments.)\n" exp += " Output:\n" - exp += " Converts a SeleniumBase Python file into one that uses\n" - exp += " the Page Object Pattern by converting page selectors\n" - exp += ' into objects stored in a "page_objects.py" file that is\n' - exp += " autogenerated and stored in the same folder as tests.\n" - exp += ' (seleniumbase "objectify" has the same outcome as\n' - exp += ' combining "extract-objects" with "inject-objects")\n' + exp += " Converts a SeleniumBase Python file into one that uses\n" + exp += " the Page Object Pattern by converting page selectors\n" + exp += ' into objects stored in a "page_objects.py" file that is\n' + exp += " autogenerated and stored in the same folder as tests.\n" + exp += ' (seleniumbase "objectify" has the same outcome as\n' + exp += ' combining "extract-objects" with "inject-objects")\n' raise Exception("INVALID RUN COMMAND!\n\n%s" % exp) def invalid_inject_objects_run_command(): exp = " ** inject-objects **\n\n" exp += " Usage:\n" - exp += " seleniumbase inject-objects [SELENIUMBASE_PYTHON_FILE]\n" + exp += " seleniumbase inject-objects [SELENIUMBASE_PYTHON_FILE]\n" exp += " Options:\n" - exp += " -c, --comments (Add object selectors to the comments.)\n" - exp += " (Default: No added comments.)\n" + exp += " -c, --comments (Add object selectors to the comments.)\n" + exp += " (Default: No added comments.)\n" exp += " Output:\n" - exp += ' Takes the page objects found in the "page_objects.py"\n' - exp += " file and uses those to replace matching selectors in\n" - exp += " the selected seleniumbase Python file.\n" + exp += ' Takes the page objects found in the "page_objects.py"\n' + exp += " file and uses those to replace matching selectors in\n" + exp += " the selected seleniumbase Python file.\n" raise Exception("INVALID RUN COMMAND!\n\n%s" % exp) def invalid_extract_objects_run_command(): exp = " ** extract-objects **\n\n" exp += " Usage:\n" - exp += " seleniumbase extract-objects [SELENIUMBASE_PYTHON_FILE]\n" + exp += " seleniumbase extract-objects [SELENIUMBASE_PYTHON_FILE]\n" exp += " Output:\n" - exp += " Creates page objects based on selectors found in a\n" - exp += " seleniumbase Python file and saves those objects to the\n" - exp += ' "page_objects.py" file in the same folder as the tests.\n' + exp += " Creates page objects based on selectors found in a\n" + exp += " seleniumbase Python file and saves those objects to the\n" + exp += ' "page_objects.py" file in the same folder as the tests.\n' raise Exception("INVALID RUN COMMAND!\n\n%s" % exp) def invalid_revert_objects_run_command(): exp = " ** revert-objects **\n\n" exp += " Usage:\n" - exp += " seleniumbase revert-objects [SELENIUMBASE_PYTHON_FILE]\n" + exp += " seleniumbase revert-objects [SELENIUMBASE_PYTHON_FILE]\n" exp += " Options:\n" - exp += " -c, --comments (Keep existing comments for the lines.)\n" - exp += " (Default: No comments are kept.)\n" + exp += " -c, --comments (Keep existing comments for the lines.)\n" + exp += " (Default: No comments are kept.)\n" exp += " Output:\n" - exp += ' Reverts the changes made by "seleniumbase objectify" or\n' - exp += ' "seleniumbase inject-objects" when run against a\n' - exp += " seleniumbase Python file. Objects will get replaced by\n" - exp += ' selectors stored in the "page_objects.py" file.\n' + exp += ' Reverts the changes made by "seleniumbase objectify" or\n' + exp += ' "seleniumbase inject-objects" when run against a\n' + exp += " seleniumbase Python file. Objects will get replaced by\n" + exp += ' selectors stored in the "page_objects.py" file.\n' raise Exception("INVALID RUN COMMAND!\n\n%s" % exp) diff --git a/seleniumbase/console_scripts/sb_print.py b/seleniumbase/console_scripts/sb_print.py index 610365417fa..105846aadb1 100644 --- a/seleniumbase/console_scripts/sb_print.py +++ b/seleniumbase/console_scripts/sb_print.py @@ -18,13 +18,13 @@ def invalid_run_command(msg=None): exp = " ** print **\n\n" exp += " Usage:\n" - exp += " seleniumbase print [FILE] [OPTIONS]\n" - exp += " OR: sbase print [FILE] [OPTIONS]\n" + exp += " seleniumbase print [FILE] [OPTIONS]\n" + exp += " OR: sbase print [FILE] [OPTIONS]\n" exp += " Options:\n" - exp += " -n (Add line Numbers to the rows)\n" + exp += " -n (Add line Numbers to the rows)\n" exp += " Output:\n" - exp += " Prints the code/text of any file\n" - exp += " with syntax-highlighting.\n" + exp += " Prints the code/text of any file\n" + exp += " with syntax-highlighting.\n" if not msg: raise Exception("INVALID RUN COMMAND!\n\n%s" % exp) else: @@ -61,13 +61,6 @@ def get_width(line): def main(): - if ( - "win32" in sys.platform - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c5 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX c7 = colorama.Fore.BLACK + colorama.Back.MAGENTA cr = colorama.Style.RESET_ALL diff --git a/seleniumbase/console_scripts/sb_recorder.py b/seleniumbase/console_scripts/sb_recorder.py index 173ee954839..132f07be9da 100644 --- a/seleniumbase/console_scripts/sb_recorder.py +++ b/seleniumbase/console_scripts/sb_recorder.py @@ -45,13 +45,6 @@ def set_colors(use_colors): c4 = "" cr = "" if use_colors: - if ( - "win32" in sys.platform - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c0 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c1 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX c2 = colorama.Fore.RED + colorama.Back.LIGHTYELLOW_EX diff --git a/seleniumbase/fixtures/base_case.py b/seleniumbase/fixtures/base_case.py index b761a46ea54..f97a1cc5aff 100644 --- a/seleniumbase/fixtures/base_case.py +++ b/seleniumbase/fixtures/base_case.py @@ -16112,8 +16112,6 @@ def tearDown(self): if is_windows: c1 = colorama.Fore.RED + colorama.Back.LIGHTRED_EX cr = colorama.Style.RESET_ALL - if hasattr(colorama, "just_fix_windows_console"): - colorama.just_fix_windows_console() msg = msg.replace("❌", c1 + "><" + cr) print(msg) else: @@ -16121,8 +16119,6 @@ def tearDown(self): if is_windows: c2 = colorama.Fore.GREEN + colorama.Back.LIGHTGREEN_EX cr = colorama.Style.RESET_ALL - if hasattr(colorama, "just_fix_windows_console"): - colorama.just_fix_windows_console() msg = msg.replace("✅", c2 + "<>" + cr) print(msg) if self.dashboard: diff --git a/seleniumbase/plugins/pytest_plugin.py b/seleniumbase/plugins/pytest_plugin.py index f251c5170ab..bbab084e8a3 100644 --- a/seleniumbase/plugins/pytest_plugin.py +++ b/seleniumbase/plugins/pytest_plugin.py @@ -130,10 +130,6 @@ def pytest_addoption(parser): cr = "" if "linux" not in sys.platform: # This will be seen when typing "pytest --help" on the command line. - if is_windows and hasattr(colorama, "just_fix_windows_console"): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX c3 = colorama.Fore.MAGENTA + colorama.Back.LIGHTYELLOW_EX @@ -1957,10 +1953,6 @@ def pytest_collection_finish(session): c1 = "" cr = "" if "linux" not in sys.platform: - if is_windows and hasattr(colorama, "just_fix_windows_console"): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX cr = colorama.Style.RESET_ALL if sb_config._multithreaded: diff --git a/seleniumbase/plugins/sb_manager.py b/seleniumbase/plugins/sb_manager.py index 4fb800e71b5..d35e2806ce1 100644 --- a/seleniumbase/plugins/sb_manager.py +++ b/seleniumbase/plugins/sb_manager.py @@ -249,6 +249,7 @@ def SB( interval (float): SECONDS (Autoplay interval for SB Slides & Tour steps.) time_limit (float): SECONDS (Safely fail tests that exceed the time limit) """ + import colorama import os import sys import time @@ -261,7 +262,6 @@ def SB( sb_config_backup = sb_config sb_config._do_sb_post_mortem = False - is_windows = shared_utils.is_windows() sys_argv = sys.argv arg_join = " ".join(sys_argv) archive_logs = False @@ -1169,11 +1169,6 @@ def SB( test_name = None terminal_width = shared_utils.get_terminal_width() if test: - import colorama - if is_windows and hasattr(colorama, "just_fix_windows_console"): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c1 = colorama.Fore.GREEN b1 = colorama.Style.BRIGHT cr = colorama.Style.RESET_ALL diff --git a/seleniumbase/translate/translator.py b/seleniumbase/translate/translator.py index 67e87167272..6ca497d56c0 100644 --- a/seleniumbase/translate/translator.py +++ b/seleniumbase/translate/translator.py @@ -267,13 +267,6 @@ def process_test_file(code_lines, new_lang): def main(): - if ( - "win32" in sys.platform - and hasattr(colorama, "just_fix_windows_console") - ): - colorama.just_fix_windows_console() - else: - colorama.init(autoreset=True) c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX c2 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX c3 = colorama.Fore.RED + colorama.Back.LIGHTGREEN_EX