[Django]-Find element with certain text using Selenium with Python

3👍

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()

0👍

You can try this one

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

Leave a comment