Skip to content Skip to sidebar Skip to footer

Python Selenium How To Click A Button Next To Specific Text?

Repo1

Solution 1:

If you want the button div after a certain RepoX, find the span and get the following div with the Button class:

.xpath("//span[text()='Repo3']/following::div[@class='Button']")

If you did not know the class name but you know it is the next div:

 .xpath("//span[text()='Repo3']/following::div[1]")

Solution 2:

To click the "Delete" button just after the "Repo1" text:

driver.find_element_by_xpath("//span[.='Repo1']/following::div[.='Delete'][1]").click()

Post a Comment for "Python Selenium How To Click A Button Next To Specific Text?"