title: Selenium wrong scroll into view
body: <p>If some buttons are visible or not, my program is doing different actions. In order to see those buttons i need to scroll to them. </p>
  
  <p>I want to see this:
  <a href="https://i.stack.imgur.com/En83R.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/En83R.jpg" alt="enter image description here"></a></p>
  
  <p>instead i see like this:
  <a href="https://i.stack.imgur.com/9FxJr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9FxJr.jpg" alt="enter image description here"></a></p>
  
  <p>I use this code:</p>
  
  <pre><code>JavascriptExecutor je=(JavascriptExecutor) driver;
       WebElement elem=driver.findElement(By.xpath("//a[contains(.,'"+username+"')]/ancestor::div[contains(@class, 'js-answer-element')]"));
       je.executeScript("arguments[0].scrollIntoView(true)", elem);
  </code></pre>
  
  <p>How can scroll until all the square is into view?</p>