Skip to content Skip to sidebar Skip to footer

How Can I Eliminate The "accept Cookies" Popup That Blocking The Content Of Webpage?

I already spend a week trying to figure out how to dismiss the 'accept cookies' popup that keeps freezing my code.I borrowed the code from here and transformed it a bit to meet my

Solution 1:

Instead of

WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((
        By.XPATH,'//iframe[@id="appconsent"]')))
WebDriverWait(driver,10).until(EC.element_to_be_clickable((
        By.XPATH,'//button[contains(@title,"Tout Accepter")]'))).click()

Use this

WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((
        By.XPATH,"//div[@id='appconsent']//iframe")))
WebDriverWait(driver,10).until(EC.visibility_of_element_located((
        By.CSS_SELECTOR,'button.button__acceptAll'))).click()

Solution 2:

If you don't want to create an UI handle for cookies popup, you can set an argument at browser's option level:

options.add_experimental_option("prefs", {"profile.default_content_setting_values.cookies": 2})

Post a Comment for "How Can I Eliminate The "accept Cookies" Popup That Blocking The Content Of Webpage?"