Search code examples
javascriptc#selenium-webdriverjs-scrollintoview

Way to scroll element in the middle of the screen


Scrolling has always been a problem with selenium automation.

All are welcome to suggest the best and reliable way to scroll element on the middle of the screen.


Solution

  • Below is the way JavaScript allowed me to resolve the mentioned problem.

    ((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView({block: 'center'});", PassIWebElementOverHere);