MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / find_elements

Method find_elements

py/selenium/webdriver/remote/webelement.py:568–596  ·  view source on GitHub ↗

Find elements given a By strategy and locator. Args: by: The locating strategy to use. Default is `By.ID`. Supported values include: - By.ID: Locate by element ID. - By.NAME: Locate by the `name` attribute. - By.XPATH: Locate by an

(self, by: str | By | RelativeBy = By.ID, value: str | None = None)

Source from the content-addressed store, hash-verified

566 return self._execute(Command.FIND_CHILD_ELEMENT, {"using": by, "value": value})["value"]
567
568 def find_elements(self, by: str | By | RelativeBy = By.ID, value: str | None = None) -> list[WebElement]:
569 """Find elements given a By strategy and locator.
570
571 Args:
572 by: The locating strategy to use. Default is `By.ID`. Supported values include:
573 - By.ID: Locate by element ID.
574 - By.NAME: Locate by the `name` attribute.
575 - By.XPATH: Locate by an XPath expression.
576 - By.CSS_SELECTOR: Locate by a CSS selector.
577 - By.CLASS_NAME: Locate by the `class` attribute.
578 - By.TAG_NAME: Locate by the tag name (e.g., "input", "button").
579 - By.LINK_TEXT: Locate a link element by its exact text.
580 - By.PARTIAL_LINK_TEXT: Locate a link element by partial text match.
581 value: The locator value to use with the specified `by` strategy.
582
583 Returns:
584 List of `WebElements` matching locator strategy found on the page.
585
586 Example:
587 element = driver.find_elements(By.ID, "foo")
588 """
589 from selenium.webdriver.support.relative_locator import RelativeBy
590
591 by, value = self._parent.locator_converter.convert(by, value)
592
593 if isinstance(by, RelativeBy):
594 return self._parent._find_elements_relative(by, root=self)
595
596 return self._execute(Command.FIND_CHILD_ELEMENTS, {"using": by, "value": value})["value"]
597
598 def __hash__(self) -> int:
599 return int(md5_hash(self._id.encode("utf-8")).hexdigest(), 16)

Callers 1

find_elementMethod · 0.95

Calls 3

_executeMethod · 0.95
convertMethod · 0.45

Tested by

no test coverage detected