Home > Back-end >  Web scraping with Python - how to click on date of same value
Web scraping with Python - how to click on date of same value

Time:11-29

I'm trying to click on the button that contains the text "30 de novembro" but when I use my code it clicks on the "30 de outubro" button How to fix?

Screenshot of HTML code

Here's the code I'm using

selecdia = navegador.find_element(by=By.LINK_TEXT, value='30')
selecdia.click()
sleep(1)

CodePudding user response:

Looks like the title attribute is the only way to uniquely identify the link you wish to click, therefore in Selenium 4 syntax:

selecdia = navegador.find_element(By.CSS_SELECTOR, "a[title='30 de novembro']")

or:

selecdia = navegador.find_element(By.XPATH, "//a[@title='30 de novembro']")
  • Related