selenium.webdriver.remote.shadowroot#
Classes
|
- class ShadowRoot(session, id_)[source]#
Bases:
object- property id: str#
- find_element(by='id', value=None)[source]#
Find an element inside a shadow root given a By strategy and locator.
- Parameters:
by (str | 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.
value (str | None) – The locator value to use with the specified by strategy.
- Returns:
The first matching WebElement found on the page.
- Return type:
Example
>>> element = driver.find_element(By.ID, "foo")
- find_elements(by='id', value=None)[source]#
Find elements inside a shadow root given a By strategy and locator.
- Parameters:
by (str | 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.
value (str | None) – The locator value to use with the specified by strategy.
- Returns:
List of WebElements matching locator strategy found on the page.
- Return type:
list[WebElement]
Example
>>> element = driver.find_elements(By.ID, "foo")