title: Scrolling issue in Laravel Dusk
body: <p>I'm trying to do test cases for my application on Laravel 6.0 with Dusk. I'm facing some difficulties in finding the element, while browsing through few topics I achieved solutions through scrolling the browser. As per the documentation I created a macro in my <code>ServiceProvider</code>:</p>
  
  <pre><code>Browser::macro('scrollToElement', function ($element = null) {
      $this-&gt;script("$('html, body').animate({ scrollTop: $('$element').offset().top }, 0);");
  
      return $this;
  });
  </code></pre>
  
  <p>I can easily use this and scroll my elements, but I have sticky head bar which comes while scrolling the top element. I need to make visible one element which is on top of the table:</p>
  
  <p><a href="https://i.stack.imgur.com/jtP6P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jtP6P.png" alt="enter image description here"></a></p>
  
  <p>Button which I want to achieve is circled with red color. When I do scroll I get screenshot from Dusk where I can see my button has been hidden by the header.</p>
  
  <p><a href="https://i.stack.imgur.com/Katxz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Katxz.png" alt="enter image description here"></a></p>
  
  <p>My code looks like:</p>
  
  <pre><code>$browser-&gt;maximize();
  $browser-&gt;scrollToElement('#company-add-button')
          -&gt;pause(500)
  </code></pre>
  
  <p>In fact I tried modifying the <code>x,y</code> values of offset/window, but no luck:</p>
  
  <pre><code>Browser::macro('scrollToElement', function ($element = null) {
      $this-&gt;script("$('html, body').animate({ scrollTop: parseInt($('$element').offset().top, 10) + 100 }, 0);");
  
      return $this;
  });
  </code></pre>