I want to click the download button but it does not work.
I tried:
driver.find_element_by_xpath("""//button[contains(text(),'Download')]]""").click()
Error message is
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//button[contains(text(),'Download')]]' is not a valid XPath expression.
and tried this code:
driver.find_element_by_xpath("""//*[@id="Download"]""").click()
Error message is:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="Download"]"}
What`s the problem?
Here is my code:
from selenium import webdriver
import time
search = "Acid Value"
driver = webdriver.Chrome('chromedriver.exe')
driver.implicitly_wait(10)
driver.get("https://pubchem.ncbi.nlm.nih.gov/classification/#hid=72")
driver.find_element_by_xpath("//span[contains(text(), 'Chemical and Physical Properties')]").click() # click Chemical and Physical Properties button
driver.find_element_by_xpath("//span[contains(text(), 'Experimental Properties')]").click() # click Experimental Properties button
driver.find_element_by_xpath(f"//span[contains(text(),'{search}')]/parent::li/descendant::span[contains(@class, 'ui-button-text')][2]").click()
#click the Desired properties
driver.implicitly_wait(10)
driver.find_element_by_xpath("""//button[contains(text(),'Download')]]""").click() # error occur here !
driver.implicitly_wait(100)
driver.find_element_by_xpath("""//button[contains(text(),'SDF')]]""").click() #click the sdf download button
driver.implicitly_wait(100)
""" """instead of single" "//buttonand display text in every button - maybe there is no button withDownload. Or maybe it has different text, with some extra chars. Or maybe it is in some tag inside button.]in xpath"""//button[contains(text(),'Download')]]"""- you have to remove last]