Python Forum
How to accept facebook cookies using python selenium? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to accept facebook cookies using python selenium? (/thread-41911.html)



How to accept facebook cookies using python selenium? - pablo86ad - Apr-06-2024

I have a problem clicking the facebook accept cookies button.
Thank you for your help

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time

service = Service(executable_path="chromedriver.exe")
driver = webdriver.Chrome(service=service)

driver.get("https://www.facebook.com/100071044756969/videos/1180978660013442")
time.sleep(5)
driver.find_elements(By.XPATH, "//button[contains(string(), 'Allow essential and optional cookies')]")[0].click()

driver.quit()