selenium.webdriver.remote.shadowroot¶
Classes
|
- class selenium.webdriver.remote.shadowroot.ShadowRoot(session, id_)[source]¶
- property id: str¶
- find_element(by: str = 'id', value: str | None = None)[source]¶
Find an element inside a shadow root 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 XPath expression.
By.CSS_SELECTOR: Locate by a CSS selector.
By.CLASS_NAME: Locate by the class attribute.
By.TAG_NAME: Locate by the tag name (e.g., “input”, “button”).
By.LINK_TEXT: Locate a link element by its exact text.
By.PARTIAL_LINK_TEXT: Locate a link element by partial text match.
RelativeBy: Locate elements relative to a specified root element.
value: The locator value to use with the specified by strategy.
- Returns:
The first matching WebElement found on the page.
- Example:
>>> element = driver.find_element(By.ID, "foo")
- find_elements(by: str = 'id', value: str | None = None) list[source]¶
Find elements inside a shadow root 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 XPath expression.
By.CSS_SELECTOR: Locate by a CSS selector.
By.CLASS_NAME: Locate by the class attribute.
By.TAG_NAME: Locate by the tag name (e.g., “input”, “button”).
By.LINK_TEXT: Locate a link element by its exact text.
By.PARTIAL_LINK_TEXT: Locate a link element by partial text match.
RelativeBy: Locate elements relative to a specified root element.
value: The locator value to use with the specified by strategy.
- Returns:
List of WebElements matching locator strategy found on the page.
- Example:
>>> element = driver.find_elements(By.ID, "foo")