Find element with certain text using Selenium with Python Find element with certain text using Selenium with Python selenium selenium

Find element with certain text using Selenium with Python


If you want to improve the code readability, you should see to follow a page object pattern.

A first step would be to define the locator in a variable with an explicit name:

from selenium.webdriver.common.by import By
item_wine_pinot_noir = (By.XPATH, "//a/h4[text()='%s']" % "Pinneau noir")browser.find_element(*item_wine_pinot_noir).click()


You can try this one

self.browser.find_element_by_link_text('item I want').click()