Home > Blockchain >  Python Selenium: Find child of sibling in a table and click it
Python Selenium: Find child of sibling in a table and click it

Time:06-13

I have a table and I want to click every checkbox on a row containing the word empty. The checkbox is a child of a sibling in the HTML-code (I hope I'm using the correct terms). Screenshot of HTML-code.

I've managed to make a list of of all elements containing empty with this:

empty = driver.find_elements_by_xpath("//*[contains(text(),'empty')]")

How can I use this list to find the checkbox in the same row? I'm using Selenium with Python.

CodePudding user response:

try one of these this xpath :

//tr[td[contains(text(),'empty')]]//input

//td[contains(text(),'empty')]/preceding-sibling::td/input
  • Related