1

I tried to get all pages from a link but I got the following error:

ElementClickInterceptedException: Message: element click intercepted: Element <a class="page-numbers" href="http://www.legorafi.fr/category/france/politique/page/.../">2</a> is not clickable at point (499, 628). Other element would receive the click: <iframe frameborder="0" src="https://c328c220ff427adeda30b2e2b65afcbb.safeframe.googlesyndication.com/safeframe/1-0-37/html/container.html" id="google_ads_iframe_/4490027/LegorafiHB_MTF_728x90_0" title="3rd party ad content" name="" scrolling="no" marginwidth="0" marginheight="0" width="728" height="90" data-is-safeframe="true" sandbox="allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation-by-user-activation" data-google-container-id="5" style="border: 0px; vertical-align: bottom;" data-load-complete="true"></iframe>

Here is my code:

from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome(executable_path="/Users/personal_name/Downloads/chromedriver 4")
url = 'http://www.legorafi.fr/category/france/politique'
driver.get(url)

WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"div#appconsent>iframe")))
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.button--filled>span.baseText"))).click()

page_number = 1
while True:
    try:
        link = driver.find_element_by_xpath('//*[@id="main"]/div[5]/div/a[1]')
    except NoSuchElementException:
        break
    link.click()
    print(driver.current_url)
    page_number += 1

I tried WebDriverWait(driver, 20).until(EC.f..) but it doesn't work

LJRB
  • 199
  • 2
  • 11

0 Answers0