finish the rest part of chrome examples and verify them on mac arm64
This commit is contained in:
@@ -25,6 +25,27 @@ def is_expected_active_tab(active_tab_info: Dict[str, str], rule: Dict[str, Any]
|
||||
logger.error(f"Unknown type: {match_type}")
|
||||
return 0
|
||||
|
||||
# rules[expected] is a string-formatted regex
|
||||
def is_expected_url_pattern_match(result, rules) -> float:
|
||||
"""
|
||||
This function is used to search the expected pattern in the url using regex.
|
||||
result is the return value of function "activte_tab_info" or return value of function "get_active_url_from_accessTree"
|
||||
"""
|
||||
if type(result)== dict:
|
||||
result_url = result["url"]
|
||||
print("result url: {}".format(result_url))
|
||||
else:
|
||||
result_url = result
|
||||
# expect_regex = re.compile(rules["expected"])
|
||||
patterns = rules["expected"]
|
||||
print("expected_regex: {}".format(patterns))
|
||||
for pattern in patterns:
|
||||
match = re.search(pattern, result_url)
|
||||
print(match)
|
||||
if not match:
|
||||
return 0.
|
||||
return 1.
|
||||
|
||||
def is_expected_tabs(open_tabs: List[Dict[str, str]], rule: Dict[str, Any]) -> float:
|
||||
"""
|
||||
Checks if the expected tabs are open in Chrome.
|
||||
|
||||
Reference in New Issue
Block a user