title: Trouble getting the screenshot of any element after zooming in
body: <p>I'm trying to take a screenshot of a desired portion from a webpage using python in combination with selenium. When I execute my script, I do get a screenshot but that is not what I intended to let the script grab. </p>
  
  <p>I wish to grab the portion shown in <code>Desired one</code> below instead of <code>Current output</code>. To get the <code>screenshot</code> exactly how it is shown in the <code>Desired one</code>, the script has to click on that <strong><em>+</em></strong> button right next to that image to make it wider in order for the dots on the gallery to be visible. </p>
  
  <p>However, the current approach takes only the screenshot of the partial portion of that image. Moreover, it grabs unwanted portion as well.</p>
  
  <p><a href="https://www1.ticketmaster.com/celine-dion-courage-world-tour/event/0600567BFDB0AB48" rel="noreferrer">Webpage link</a></p>
  
  <p>I've tried with:</p>
  
  <pre><code>import time
  from selenium import webdriver
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  
  link = 'https://www1.ticketmaster.com/celine-dion-courage-world-tour/event/0600567BFDB0AB48'
  
  def start_script():
      options = webdriver.ChromeOptions()
      options.add_argument("--start-maximized")
      driver = webdriver.Chrome(options=options)
      return driver
  
  def get_links(url):
      driver = start_script()
      driver.get(url)
      try:
          button = WebDriverWait(driver,20).until(EC.visibility_of_element_located((By.CSS_SELECTOR,"#landingPricingMessage button.pricing-landing__modal-btn")))
      except Exception: button = ""
      if button: button.click()
  
      try:
          zoom = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.CSS_SELECTOR,"button[class='zoomer__control--zoomin'] &gt; svg[class='zoomin']")))
      except Exception: zoom = ""
  
      if zoom:
          for _ in range(3):
              zoom.click()
              time.sleep(2)
      try:
          element = WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.CSS_SELECTOR,"svg[data-component='svg'][class='map__svg']")))
      except Exception: element = ""
  
      if element:
          element.screenshot('gallery.png')
          driver.quit()
          return 0
  
      else:
          driver.quit()
          return get_links(url)
  
  
  if __name__ == '__main__':
      get_links(link)
  </code></pre>
  
  <p><strong><em>I even tried like this but the output is still the same:</em></strong></p>
  
  <pre><code>def get_links(url):
      driver = start_script()
      driver.get(url)
      try:
          elem = WebDriverWait(driver,5).until(EC.visibility_of_element_located((By.XPATH,"//h1[contains(.,'Pardon the Interruption')]"))).text
      except Exception: elem = ""
  
      if elem:
          driver.quit()
          return get_links(url)
      else:
          element = WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.CSS_SELECTOR,"svg[data-component='svg'][class='map__svg']")))
          location = element.location
          size = element.size
          png = driver.get_screenshot_as_png()
          im = Image.open(BytesIO(png))
          left = location['x']
          top = location['y']
          right = location['x'] + size['width']
          bottom = location['y'] + size['height']
          im = im.crop((left, top, right, bottom))
          im.save('screenshot.png')
          driver.quit()
          return 0
  </code></pre>
  
  <p><a href="https://filebin.net/z1oxmhhlwuh98cgs" rel="noreferrer">Current output</a></p>
  
  <p><a href="https://filebin.net/622820wggd7c14bz" rel="noreferrer">Desired one</a></p>
  
  <blockquote>
    <p>In the desired output image I've marked an area which should be kicked out as it is not the part of that image.</p>
  </blockquote>
  
  <p><strong><em>How can I get only the screenshot of any element even after zooming in?</em></strong></p>
  
  <p>Note: I used proxies for the script to work as there is a bot protection mechanism active in there. I'm only after the logic to get the desired output.</p>