Last active
April 5, 2021 15:52
-
-
Save nadvolod/2c5ce6c43b44fc2dc2a17cb34531597d to your computer and use it in GitHub Desktop.
How to scroll an element into a view using Selenium c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
element = driver.FindElement(By.LinkText("Click me using this link text!")); | |
//this will scroll the element and center it for interaction | |
var js = (IJavaScriptExecutor)Driver; | |
js.ExecuteScript("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center'})", element); | |
//this one will scroll the element into view for interactions | |
IJavaScriptExecutor je = (IJavaScriptExecutor)driver; | |
je.ExecuteScript("arguments[0].scrollIntoView(false);", element); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For C# try this