MCPcopy
hub / github.com/streamlit/streamlit / get_element_by_key

Function get_element_by_key

e2e_playwright/shared/app_utils.py:1123–1142  ·  view source on GitHub ↗

Get an element with the given user-defined key. Parameters ---------- locator : Locator The locator to search for the element. key : str The user-defined key of the element Returns ------- Locator The element.

(locator: Locator | Page, key: str)

Source from the content-addressed store, hash-verified

1121
1122
1123def get_element_by_key(locator: Locator | Page, key: str) -> Locator:
1124 """Get an element with the given user-defined key.
1125
1126 Parameters
1127 ----------
1128 locator : Locator
1129 The locator to search for the element.
1130
1131 key : str
1132 The user-defined key of the element
1133
1134 Returns
1135 -------
1136 Locator
1137 The element.
1138
1139 """
1140 class_name = re.sub(r"[^a-zA-Z0-9_-]", "-", key.strip())
1141 class_name = f"st-key-{class_name}"
1142 return locator.locator(f".{class_name}")
1143
1144
1145def expand_sidebar(app: Page) -> Locator:

Calls 1

locatorMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…