WebElement.find_element_by_xpath

def find_element_by_xpath(
self,
xpath: str,
timeout: int = 30
) -> WebElement

In the active browser, find element by the given XPath.

Parameters:
xpath[Required]: str
   the XPath of the element to find.
timeout: int
   Timeout for the operation, the unit is second, and the default value is 30 seconds.

Returns:
WebElement object.

Example:


from clicknium import clicknium as cc

chrome_tab = cc.chrome.open("https://bing.com/images")

# find elements by XPath
element = chrome_tab.find_element_by_xpath("//*[@id=\"ilp_t\"]")

# find sub element by XPath
subelement = element.find_element_by_xpath(".//*[@id=\"ilp_t\"]/div[1]/div/*")
subelement.highlight()

Previousfind_elementNextfind_element_by_css_selector

What are your feelings
Updated on 29 August 2023