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

Method find_elements

seleniumbase/fixtures/base_case.py:2228–2243  ·  view source on GitHub ↗

Returns a list of matching WebElements. Elements could be either hidden or visible on the page. If "limit" is set and > 0, will only return that many elements.

(self, selector, by="css selector", limit=0)

Source from the content-addressed store, hash-verified

2226 )
2227
2228 def find_elements(self, selector, by="css selector", limit=0):
2229 """Returns a list of matching WebElements.
2230 Elements could be either hidden or visible on the page.
2231 If "limit" is set and > 0, will only return that many elements."""
2232 selector, by = self.__recalculate_selector(selector, by)
2233 if self.__is_cdp_swap_needed():
2234 elements = self.cdp.select_all(selector)
2235 if limit and limit > 0 and len(elements) > limit:
2236 elements = elements[:limit]
2237 return elements
2238 self.wait_for_ready_state_complete()
2239 time.sleep(0.05)
2240 elements = self.driver.find_elements(by=by, value=selector)
2241 if limit and limit > 0 and len(elements) > limit:
2242 elements = elements[:limit]
2243 return elements
2244
2245 def find_visible_elements(self, selector, by="css selector", limit=0):
2246 """Returns a list of matching WebElements that are visible.

Callers 5

get_select_optionsMethod · 0.95
highlight_elementsMethod · 0.95
select_allMethod · 0.95
find_visible_elementsFunction · 0.45

Calls 5

__is_cdp_swap_neededMethod · 0.95
select_allMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected