Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
import time
driver = webdriver.Chrome(r'C:\Users\Admin\Desktop\Python\chromedriver.exe')
driver.get('https://google.com/xhtml')
time.sleep(2) # seconds until popup appears
try: # 2 different popups
frame = driver.find_element_by_xpath('//*[@id="cnsw"]/iframe') #<-locating chrome cookies consent frame
driver.switch_to.frame(frame)
driver.find_element_by_xpath('//*[@id="introAgreeButton"]').click()#<-looking for introAgreeButton button, but seems google has changed its name since and it only works in old chrome versions.
except NoSuchElementException:
driver.find_element_by_xpath('//*[@id="L2AGLb"]').click() #<- pay attention to new id.
search_field = driver.find_element_by_name('q')
search_field.send_keys('google')
search_field.submit()
time.sleep(5)
driver.quit()