(shell_command)
| 3047 | |
| 3048 | |
| 3049 | def main(shell_command): |
| 3050 | expected_arg = "[A SeleniumBase Python file]" |
| 3051 | num_args = len(sys.argv) |
| 3052 | command_args = sys.argv[2:] |
| 3053 | |
| 3054 | add_comments = False |
| 3055 | if shell_command == "objectify" or ( |
| 3056 | shell_command == "inject-objects" |
| 3057 | or (shell_command == "revert-objects") |
| 3058 | ): |
| 3059 | if len(command_args) >= 2: |
| 3060 | options = command_args[1:] |
| 3061 | for option in options: |
| 3062 | if option == "-c" or option == "--comments": |
| 3063 | add_comments = True |
| 3064 | else: |
| 3065 | invalid_run_command(shell_command) |
| 3066 | |
| 3067 | if ( |
| 3068 | sys.argv[0].split("/")[-1] == "seleniumbase" |
| 3069 | or (sys.argv[0].split("\\")[-1] == "seleniumbase") |
| 3070 | or (sys.argv[0].split("/")[-1] == "sbase") |
| 3071 | or (sys.argv[0].split("\\")[-1] == "sbase") |
| 3072 | ): |
| 3073 | if num_args < 3: |
| 3074 | invalid_run_command(shell_command) |
| 3075 | elif num_args > 3: |
| 3076 | if shell_command == "extract-objects": |
| 3077 | invalid_run_command(shell_command) |
| 3078 | else: |
| 3079 | pass |
| 3080 | else: |
| 3081 | pass |
| 3082 | else: |
| 3083 | invalid_run_command(shell_command) |
| 3084 | |
| 3085 | seleniumbase_file = command_args[0] |
| 3086 | if not seleniumbase_file.endswith(".py"): |
| 3087 | raise Exception( |
| 3088 | "\n\n`%s` is not a Python file!\n\n" |
| 3089 | "Expecting: %s\n" % (seleniumbase_file, expected_arg) |
| 3090 | ) |
| 3091 | |
| 3092 | with open(seleniumbase_file, mode="r", encoding="utf-8") as f: |
| 3093 | all_code = f.read() |
| 3094 | if "def test_" not in all_code: |
| 3095 | raise Exception( |
| 3096 | "\n\n`%s` is not a valid SeleniumBase unittest file!\n" |
| 3097 | "\nExpecting: %s\n" % (seleniumbase_file, expected_arg) |
| 3098 | ) |
| 3099 | code_lines = all_code.split("\n") |
| 3100 | seleniumbase_lines, page_selectors, changed = process_test_file(code_lines) |
| 3101 | var_names, existing_selectors, selector_list_dict = scan_objects_file() |
| 3102 | new_page_selectors = [] |
| 3103 | |
| 3104 | for selector in page_selectors: |
| 3105 | selector = optimize_selector(selector) |
| 3106 | if selector not in existing_selectors: |
no test coverage detected
searching dependent graphs…