Hey Disha, following piece of code worked for me to scroll to a web element:
def scroll_to_element_action(element, locator=nil)
script = "var viewPortHeight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);" + "var elementTop = arguments[0].getBoundingClientRect().top;" + "window.scrollBy(0, elementTop-(viewPortHeight/2));"
element = element.nil? ? find(locator) : element
execute_script(script, element)
end