I'm looking to click on a button that appear when you have no cookies from this website, named "accéder au site". Here is the process to have this button :
- No cookies
- Go to https://www.allocine.fr
- Click the "Accepter et accéder gratuitement" button
- Then a pop-up for promoting a movie appear with a "accéder au site" button in order to skip it. (the pop-up last for about 5/10s)
I'm using Selenium (Python).
This is the website : https://www.allocine.fr I tried many things such as css selector, partial link text, switching to frame but nothing is working. I also thought that my problem was that I have to wait before the button appears, but this isn't working too.
Here is my code :
from yggtorrentscraper import YggTorrentScraperSelenium
from selenium import webdriver
options = webdriver.ChromeOptions()
options.headless = False
options.add_argument("--log-level=3")
prefs = {"profile.default_content_setting_values.notifications" : 2}
options.add_experimental_option("prefs",prefs)
PATH_CHROME_DRIVER = "C:\\Users\\Kevin\\Desktop\\chromedriver.exe"
driver = webdriver.Chrome(PATH_CHROME_DRIVER, options=options)
driver.get("https://www.allocine.fr")
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '/html/body/div[1]/div/div/div/div/div/div[2]/div/span/div/button[2]'))).click()
#not working
#WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '/html/body/div[2]/div/a'))).click()
Here is also the HTML of the button
<div id="dfp_interstitial">
<div id="dfp_interstitial__top">
<div id="dfp_interstitial__top-logo" style="background-image: url("https://lh3.googleusercontent.com/-PBjnn15gFS4/XJzvx16iKdI/AAAAAAAADro/yVpahUmuWwMxthTXopnE0lLgJ0zJxG0qgCK8BGAs/s0/2019-03-28.png");"></div>
<div id="dfp_interstitial__top-close">
accéder au site <span class="dfp_interstitial__arrow-right"></span><span class="dfp_interstitial__arrow-right"></span>
</div>
</div>
<a id="dfp_interstitial__click" target="_blank">
<img id="dfp_interstitial__image" src="https://tpc.googlesyndication.com/simgad/5287997328350019355?" style="max-width: 1280px;">
</a>
I have really no idea what I'm doing wrong. Any help appreciated !