How can I automatically click on the Facebook "Allow all cookies" button? I can't find the part of the code useful for clicking. The link is this
CodePudding user response:
To click on the Allow all cookies button you have to induce
ele = driver.find_element_by_css_selector("div[aria-label='Allow all cookies']")
# or
ele = driver.find_element_by_xpath(span[contains(text(), 'Allow all cookies')])
CodePudding user response:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from time import sleep
class Test():
def __init__(self):
self.driver = webdriver.Chrome()
self.driver.get('https://www.facebook.com/privacy/consent/user_cookie_choice/?source=pft_user_cookie_choice')
WebDriverWait(self.driver, 86400).until(lambda x: x.find_element_by_xpath('/html/body/div[3]/div[2]/div/div/div/div/div[3]/button[2]')).click()
sleep(100)
Test()