Answers for "find child element selenium python"

2

python selenium get child element

from selenium import webdriver

driver = webdriver.Firefox()
driver.get("http://www.stackoverflow.com")

#Here you get the parent element
header = driver.find_element_by_id("header")

#Here you can get all the child elements by css:
all_children_by_css = header.find_elements_by_css_selector("*")

#Or here you can get all the child elements by xpath:
all_children_by_xpath = header.find_elements_by_xpath(".//*")

#And if you just want one element you can take it by index:
all_children_by_xpath[0] #for first item
all_children_by_xpath[1] #for the 2
Posted by: Guest on July-09-2021

Code answers related to "find child element selenium python"

Python Answers by Framework

Browse Popular Code Answers by Language