Skip to content

Commit 4512291

Browse files
committed
expect_locator_values_in_list change to find elements via xpath all at once
1 parent f187256 commit 4512291

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

tests/playwright/controls.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,20 +1090,18 @@ def expect_locator_values_in_list(
10901090
loc_container_orig = loc_container
10911091

10921092
# Find all items in set
1093-
for i in range(len(arr)):
1094-
# Get ith element of type
1095-
loc_item.nth(i)
1096-
# # Make sure that element has the correct attribute value
1097-
# has_locator = has_locator.locator(
1098-
# f"xpath=self::*[{_xpath_match_str(key, item)}]"
1099-
# )
1100-
#
1101-
# # Given the container, make sure it contains this locator
1102-
# loc_container = loc_container.locator(
1103-
# # Return self
1104-
# "xpath=.",
1105-
# has=has_locator,
1106-
# )
1093+
xpath = f"""xpath=self::*[{
1094+
" or ".join([
1095+
_xpath_match_str(key, item)
1096+
for item in arr
1097+
])
1098+
}]"""
1099+
1100+
loc_container = loc_container.locator(
1101+
# Return self
1102+
"xpath=.",
1103+
has=loc_item.locator(xpath),
1104+
)
11071105

11081106
# Make sure other items are not in the set.
11091107
# If we know all elements are contained in the container

0 commit comments

Comments
 (0)