I am trying to crawl some articles from a website and before doing so, I need to click the "Cookies Agree" using Selenium in Python.
But unfortunately, I keep getting either TimeoutException or NoSuchElementException!
I've figured out that the click button is within iframe, so I've switched to it and clicked the consent button.
homepage = 'link'
driver.maximize_window()
driver.get(homepage)
driver.implicitly_wait(5)
driver.switch_to.frame('location')
try:
consent = wait(driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, 'classname')))
consent.click()
except TimeoutException :
print('timeoutexception')
driver.switch_to.default_content()
But still I just can't get through the TimeoutException error.
What have I done wrong....?!