FRAMEWORK » SELENIUM » ELEMENT

Find

Methods

These are the recommended methods:

Single elementMultiple elements
find_elementfind_elements

These methods has been deprecated:

Single elementMultiple elements
find_element_by_id-
find_element_by_namefind_elements_by_name
find_element_by_xpathfind_elements_by_xpath
find_element_by_link_textfind_elements_by_link_text
find_element_by_partial_link_textfind_elements_by_partial_link_text
find_element_by_tag_namefind_elements_by_tag_name
find_element_by_class_namefind_elements_by_class_name
find_element_by_css_selectorfind_elements_by_css_selector

Examples

python
element = browser.find_element(By.ID, 'foo')

Nesting is possible.

python
browser.find_element(By.ID, 'foo').find_element(By.ID, 'boo')

Get the parent element.

python
parent = browser.find_element(By.ID, 'child').find_element(By.XPATH, '..')