|
| 1 | +""" |
| 2 | +SeleniumBase console scripts runner |
| 3 | +
|
| 4 | +Usage: |
| 5 | +seleniumbase [COMMAND] [PARAMETERS] |
| 6 | +
|
| 7 | +Examples: |
| 8 | +seleniumbase mkdir [DIRECTORY_NAME] |
| 9 | +seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE].py |
| 10 | +seleniumbase grid-hub start |
| 11 | +seleniumbase grid-node start --hub=127.0.0.1 |
| 12 | +""" |
| 13 | + |
| 14 | +import sys |
| 15 | +from console_scripts import sb_mkdir |
| 16 | +from integrations.selenium_grid import grid_hub |
| 17 | +from integrations.selenium_grid import grid_node |
| 18 | +from integrations.selenium_ide import convert_ide |
| 19 | + |
| 20 | + |
| 21 | +def show_usage(): |
| 22 | + show_basic_usage() |
| 23 | + print('Type "seleniumbase help" for more details.\n') |
| 24 | + |
| 25 | + |
| 26 | +def show_basic_usage(): |
| 27 | + print("") |
| 28 | + print(">>>>>>>>>>>>") |
| 29 | + print("") |
| 30 | + print('Usage: "seleniumbase [command] [parameters]"') |
| 31 | + print("") |
| 32 | + print("Commands:") |
| 33 | + print("") |
| 34 | + print(" mkdir [DIRECTORY]") |
| 35 | + print(" convert [FILENAME]") |
| 36 | + print(" grid-hub {start|stop|restart} [OPTIONS]") |
| 37 | + print(" grid-node {start|stop|restart} --hub=[HUB_IP] [OPTIONS]") |
| 38 | + print("") |
| 39 | + |
| 40 | + |
| 41 | +def show_mkdir_usage(): |
| 42 | + print(" ** mkdir **") |
| 43 | + print("") |
| 44 | + print(" Usage:") |
| 45 | + print(" seleniumbase mkdir [DIRECTORY_NAME]") |
| 46 | + print(" Output:") |
| 47 | + print(" Creates a new folder for running SeleniumBase scripts.") |
| 48 | + print(" The new folder contains default config files,") |
| 49 | + print(" sample tests for helping new users get started, and") |
| 50 | + print(" Python boilerplates for setting up customized") |
| 51 | + print(" test frameworks.") |
| 52 | + print("") |
| 53 | + |
| 54 | + |
| 55 | +def show_convert_usage(): |
| 56 | + print(" ** convert **") |
| 57 | + print("") |
| 58 | + print(" Usage:") |
| 59 | + print(" seleniumbase convert [MY_TEST.py]") |
| 60 | + print(" Output:") |
| 61 | + print(" Converts a Selenium IDE exported WebDriver unittest") |
| 62 | + print(" file into a SeleniumBase file. Adds _SB to the new") |
| 63 | + print(" file name while keeping the original file intact.") |
| 64 | + print(" Works with Katalon Recorder scripts.") |
| 65 | + print(" See: http://www.katalon.com/automation-recorder") |
| 66 | + print("") |
| 67 | + |
| 68 | + |
| 69 | +def show_grid_hub_usage(): |
| 70 | + print(" ** grid-hub **") |
| 71 | + print("") |
| 72 | + print(" Usage:") |
| 73 | + print(" seleniumbase grid-hub {start|stop|restart}") |
| 74 | + print(" Options:") |
| 75 | + print(" -v, --verbose (Increase verbosity of logging output.)") |
| 76 | + print(" (Default: Quiet logging / not verbose.)") |
| 77 | + print(" Output:") |
| 78 | + print(" Controls the Selenium Grid Hub Server, which allows") |
| 79 | + print(" for running tests on multiple machines in parallel") |
| 80 | + print(" to speed up test runs and reduce the total time") |
| 81 | + print(" of test suite execution.") |
| 82 | + print(" You can start, restart, or stop the Grid Hub server.") |
| 83 | + print("") |
| 84 | + |
| 85 | + |
| 86 | +def show_grid_node_usage(): |
| 87 | + print(" ** grid-node **") |
| 88 | + print("") |
| 89 | + print(" Usage:") |
| 90 | + print(" seleniumbase grid-node {start|stop|restart} [OPTIONS]") |
| 91 | + print(" Options:") |
| 92 | + print(" --hub=HUB_IP (The Grid Hub IP Address to connect to.)") |
| 93 | + print(" (Default: 127.0.0.1 if not set)") |
| 94 | + print(" -v, --verbose (Increase verbosity of logging output.)") |
| 95 | + print(" (Default: Quiet logging / not verbose.)") |
| 96 | + print(" Output:") |
| 97 | + print(" Controls the Selenium Grid node, which serves as a") |
| 98 | + print(" worker machine for your Selenium Grid Hub server.") |
| 99 | + print(" You can start, restart, or stop the Grid node.") |
| 100 | + print("") |
| 101 | + |
| 102 | + |
| 103 | +def show_detailed_help(): |
| 104 | + show_basic_usage() |
| 105 | + print("More Info:") |
| 106 | + print("") |
| 107 | + show_mkdir_usage() |
| 108 | + show_convert_usage() |
| 109 | + show_grid_hub_usage() |
| 110 | + show_grid_node_usage() |
| 111 | + |
| 112 | + |
| 113 | +def main(): |
| 114 | + num_args = len(sys.argv) |
| 115 | + if num_args == 1: |
| 116 | + show_usage() |
| 117 | + return |
| 118 | + elif num_args == 2: |
| 119 | + command = sys.argv[1] |
| 120 | + command_args = [] |
| 121 | + elif num_args > 2: |
| 122 | + command = sys.argv[1] |
| 123 | + command_args = sys.argv[2:] |
| 124 | + print command |
| 125 | + |
| 126 | + if command == "convert": |
| 127 | + if len(command_args) == 1: |
| 128 | + convert_ide.main() |
| 129 | + else: |
| 130 | + show_basic_usage() |
| 131 | + show_convert_usage() |
| 132 | + elif command == "mkdir": |
| 133 | + if len(command_args) == 1: |
| 134 | + sb_mkdir.main() |
| 135 | + else: |
| 136 | + show_basic_usage() |
| 137 | + show_mkdir_usage() |
| 138 | + elif command == "grid-hub": |
| 139 | + if len(command_args) >= 1: |
| 140 | + grid_hub.main() |
| 141 | + else: |
| 142 | + show_basic_usage() |
| 143 | + show_grid_hub_usage() |
| 144 | + elif command == "grid-node": |
| 145 | + if len(command_args) >= 1: |
| 146 | + grid_node.main() |
| 147 | + else: |
| 148 | + show_basic_usage() |
| 149 | + show_grid_node_usage() |
| 150 | + elif command == "help" or command == "--help": |
| 151 | + show_detailed_help() |
| 152 | + else: |
| 153 | + show_usage() |
| 154 | + |
| 155 | + |
| 156 | +if __name__ == "__main__": |
| 157 | + main() |
0 commit comments