Search code examples
testingautomated-testsbehatmink

How to use scrollTop in behat?


I have a page, when I enter into that page it will show below part only, so I want to scroll up to click one of the element present in the top of the page.How can I achieve that,I tried like below but its not working.

$this->getSession()->wait(5000, "jQuery('#page').animate({scrollTop: '-500px'}, 300)"); 

Thanks in advance.


Solution

  • You can use an action like this:

    $this->getSession()->executeScript('window.scrollTo(0,0);');