title: Click “Accept Cookies” popup with Selenium in Python
body: <p>I've been trying to scrape some information of this E-commerce website with selenium. However when I access the website I need to accept cookies to continue. This only happens when the bot accesses the website, not when I do it manually. When I try to find the corresponding element either by xpath, as I find it when I inspect the page manually I always get this error message:</p>
  <blockquote>
  <p>selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document</p>
  </blockquote>
  <p>My code is mentined below.</p>
  <pre><code>import time
  import pandas
  pip install selenium
  from selenium import webdriver
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  from selenium.webdriver.common.by import By
  from selenium.common.exceptions import TimeoutException
  from bs4 import BeautifulSoup #pip install beautifulsoup4
  
  PATH = &quot;/Users/Ziye/Desktop/Python/chromedriver&quot;
  delay = 15
  
  driver = webdriver.Chrome(PATH)
  driver.implicitly_wait(10)
  
  driver.get(&quot;https://en.zalando.de/women/?q=michael+michael+kors+taschen&quot;)
  driver.find_element_by_xpath('//*[@id=&quot;uc-btn-accept-banner&quot;]').click()
  </code></pre>
  <p>This is the HTML corresponding to the button &quot;That's ok&quot;. The XPATH is as above.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;button aria-label=&quot;&quot; id=&quot;uc-btn-accept-banner&quot; class=&quot;uc-btn uc-btn-primary&quot;&gt;
                            That’s OK &lt;span id=&quot;uc-optin-timer-display&quot;&gt;&lt;/span&gt;
                        &lt;/button&gt;
  </code></pre>
  
  <p>Does anyone know where my mistake lies?</p>