How to find button with Selenium by its text inside (Python)?

See: find_element_by_* commands are deprecated in selenium

In newer versions of selenium try:

from selenium.webdriver.common.by import By
browser.find_element(By.XPATH, '//button[text()="Outliers"]')

older versions of selenium:

browser.find_element_by_xpath('//button[text()="Outliers"]')

To update ALL of the older versions I found a nifty regex here, and then just fixup the import:

  • https://stackoverflow.com/a/70586710/2026508

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)