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)
| 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. |
no test coverage detected