selenium.webdriver.remote.shadowroot¶
Classes
|
- class selenium.webdriver.remote.shadowroot.ShadowRoot(session, id_)[source]¶
- find_element(by: str = 'id', value: str = None)[source]¶
Find an element inside a shadow root given a By strategy and locator.
Parameters:¶
- byselenium.webdriver.common.by.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.
Example:¶
element = driver.find_element(By.ID, ‘foo’)
Returns:¶
- WebElement
The first matching WebElement found on the page.
- find_elements(by: str = 'id', value: str = None)[source]¶
Find elements inside a shadow root given a By strategy and locator.
Parameters:¶
- byselenium.webdriver.common.by.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.
Example:¶
element = driver.find_element(By.ID, ‘foo’)
Returns:¶
- WebElement
list of WebElements matching locator strategy found on the page.