Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vanleantking/13ba839488e55578b0ae5502dce843f9 to your computer and use it in GitHub Desktop.
Save vanleantking/13ba839488e55578b0ae5502dce843f9 to your computer and use it in GitHub Desktop.
xpath find grandparent node contains class name
xpath find grandparent node contains class name
elem_parent_btn_download = driver.find_element_by_xpath("(//span[contains(.,'Tải về danh sách')])[4]/ancestor::div[contains(@class,'download-button-dropdown')]")
xpath find chidld node:
child_element = element.find_element_by_xpath('./')
child_element = element.find_element_by_xpath('.//')
https://stackoverflow.com/questions/66166788/get-child-element-using-xpath-selenium-python
https://stackoverflow.com/questions/20216541/selenium-find-childs-child-elements
https://stackoverflow.com/questions/68385050/selenium-python-xpath-find-element-that-has-a-child-grandchild
https://stackoverflow.com/questions/43478965/find-out-all-child-elements-xpath-from-parent-xpath-using-selenium-webdriver-in
https://stackoverflow.com/questions/24795198/get-all-child-elements
@vanleantking
Copy link
Author

find parent element by xpath on an element
elem_new_plan = driver.find_element(By.XPATH, "(//material-ripple[@aria-hidden='true'])[16]")
elem_btn_new_plan = elem_new_plan.find_element_by_xpath("..");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment