How to scroll webpage in automation tests with Mocha.js with LambdaTest cloud?

How to scroll webpage in automation tests with Mocha.js with LambdaTest cloud?

Hi Tom,

In order to scroll webpage in automation tests with Mocha.js with LambdaTest cloud, you can refer to these following steps. You can also refer to the sample test repo:

To scroll down by x (in this case 350) pixels, you can use the following line of code:

driver.executeScript("window.scrollBy(0,350)", "");

To scroll up by x (in this case 350) pixels, you can use the following line of code:

driver.executeScript("window.scrollBy(0,-350)", "");

To scroll to the bottom of the page, you can use the following line of code:

driver.executeScript("window.scrollTo(0, document.body.scrollHeight);")

Here’s the GitHub repo for the same: https://github.com/rshmimondal/Mocha-js-scroll