title: Zoom in and screenshot a specific section of a webpage (Selenium Python)
body: <p>Right now, my code screenshots a specific section of a webpage. However, since the element it's screenshotting is quite small on the webpage, the picture is also quite small. So, to solve this issue, I thought I could zoom into the page, center onto the element, screenshot the element, and then zoom out – but it's not working.</p>
  <p>When I run the following code (no zooming in):</p>
  <pre><code>theComment = driver.find_element(By.XPATH, &quot;/html/body/div[1]/div/div[2]/div[3]/div/div/div/div[2]/div[1]/div[2]/div[6]/div/div/div/div[1]&quot;)
  driver.execute_script('arguments[0].scrollIntoView({block: &quot;center&quot;});', theComment)
  theComment.screenshot('comment'+str(verified+1)+'.png')
  </code></pre>
  <p>I get the following image:</p>
  <p><a href="https://i.stack.imgur.com/sLWsP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sLWsP.png" alt="enter image description here" /></a></p>
  <p>But when I run the following code (zooming in):</p>
  <pre><code>theComment = driver.find_element(By.XPATH, &quot;/html/body/div[1]/div/div[2]/div[3]/div/div/div/div[2]/div[1]/div[2]/div[6]/div/div/div/div[1]&quot;)
  driver.execute_script(&quot;document.body.style.zoom='150%'&quot;)
  sleep(1)
  driver.execute_script('arguments[0].scrollIntoView({block: &quot;center&quot;});', theComment)
  sleep(1)
  theComment.screenshot('comment.png')
  sleep(1)
  driver.execute_script(&quot;document.body.style.zoom='100%'&quot;)
  </code></pre>
  <p>I get the following image (the screenshot is really far away from where the actual comment is, and smaller than the comment is):</p>
  <p><a href="https://i.stack.imgur.com/xAOUK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xAOUK.png" alt="enter image description here" /></a></p>
  <p>Any help would be greatly appreciated. Thank you.</p>