Scroll to element works fine if element is lower position ( scroll down ) , but in case of element is upper position ( scroll up ) it don't scroll to element in view rather it scroll one less to element ( count is not fixed may it 2 or 3 , varies ) .
I have to write explicit code for scroll up for element which is up , after ScrollIntoView , this is not consistent as scroll up count is not fixed .
I used this 2 codes one by one , but both gives same behavior
Code1 :
// Scroll to view by Action
Actions actions = new Actions(driver);
actions.MoveToElement(webElement);
actions.Perform();
Code 2:
// Scroll to view by JavaScript executer
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", webElement);
Please help me in this case , please suggest what I have to with this .