MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / main

Function main

seleniumbase/console_scripts/sb_objectify.py:3049–3194  ·  view source on GitHub ↗
(shell_command)

Source from the content-addressed store, hash-verified

3047
3048
3049def 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:

Callers 4

extract_objectsFunction · 0.70
inject_objectsFunction · 0.70
objectifyFunction · 0.70
revert_objectsFunction · 0.70

Calls 7

scan_objects_fileFunction · 0.85
get_next_var_nameFunction · 0.85
create_objects_fileFunction · 0.85
closeMethod · 0.80
invalid_run_commandFunction · 0.70
process_test_fileFunction · 0.70
optimize_selectorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…