I am currently trying to learn selenium in Python and I am having an issue clicking the "Accept All Cookies" button.
I am using:
Python v3.9
Chrome v87
This is the HTML page i am trying to scrape
Here is my code currently
# Selenium Tutorial #1 from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.action_chains import ActionChains import time driver = webdriver.Chrome(r"C:\Users\Ste1337\Desktop\chromedriver\chromedriver.exe") driver.get("https://www.currys.co.uk/gbuk/tv-and-home-entertainment/televisions/televisions/samsung-ue75tu7020kxxu-75-smart-4k-ultra-hd-hdr-led-tv-10213562-pdt.html") #search = driver.find_element_by_id(ContentPlaceHolder1_NotifyBtn) driver.implicitly_wait(10) link = driver.find_element_by_id("onetrust-accept-btn-handler") link.click try: element = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "onetrust-accept-btn-handler")) ) element.click except: driver.quit()
https://stackoverflow.com/questions/65768351/how-do-i-use-selenium-to-click-accept-all-cookies-on-a-cookie-pop-up January 18, 2021 at 11:11AM
没有评论:
发表评论