Selenium cannot find element in page

I am trying to get selenium to press the download button on this page.


I’ve been trying to use

mod = browser.find_element_by_css_selector('#method_free').click()

but I get the error

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element:


You need basically explicit waits, cause the id in HTML DOM is unique.

driver = webdriver.Chrome(driver_path)
wait = WebDriverWait(driver, 20)
wait.until(EC.element_to_be_clickable((By.ID, "method_free"))).click()

Imports :

from import WebDriverWait
from import By
from import expected_conditions as EC

Note that once you click on the download a new tab is opening up, to interact with the web element in that new window, you’d need to switch.

all_handles = driver.window_handles

and then you can interact with new windows item.