finish the rest part of chrome examples and verify them on mac arm64
This commit is contained in:
@@ -44,7 +44,9 @@ def is_in_list(result, rules) -> float:
|
||||
return 1.
|
||||
else:
|
||||
return 0.
|
||||
|
||||
|
||||
|
||||
|
||||
def fuzzy_match(result, rules) -> float:
|
||||
expect = rules["expected"]
|
||||
|
||||
@@ -135,7 +137,7 @@ def check_accessibility_tree(result: str, rules: Dict[str, Any]) -> float:
|
||||
needed. If both are present, `xpath` takes the priority.
|
||||
"text": str as the expected text content of the selected element.
|
||||
"exact": bool specifying whether exact match or fuzzy match should
|
||||
be performed. defaults to True
|
||||
be performed. defaults to True.
|
||||
}
|
||||
|
||||
Returns:
|
||||
@@ -152,6 +154,7 @@ def check_accessibility_tree(result: str, rules: Dict[str, Any]) -> float:
|
||||
raise ValueError("At least one of xpath and selectors is required")
|
||||
|
||||
if len(elements) == 0:
|
||||
print("no elements")
|
||||
return 0.
|
||||
|
||||
if "text" in rules:
|
||||
@@ -217,3 +220,19 @@ def check_json(result: str, rules: Dict[str, List[Dict[str, Union[List[str], str
|
||||
value = value[k]
|
||||
metric = metric and not _match_value_to_rule(value, r)
|
||||
return metric
|
||||
|
||||
|
||||
def check_direct_json_object(result, rules)->float:
|
||||
"""
|
||||
One of the most commonly used function to evalute.
|
||||
Compare two json objects directly.
|
||||
"""
|
||||
print("result: ")
|
||||
print(result)
|
||||
print("expected: ")
|
||||
print(rules["expected"])
|
||||
expected_json = rules["expected"]
|
||||
for key in expected_json.keys():
|
||||
if expected_json[key] != result[key]:
|
||||
return 0.
|
||||
return 1.0
|
||||
Reference in New Issue
Block a user