I'm creating some Selenium tests in JavaScript. I'm having trouble clicking on a button that is not in view (this seems to be an issue with the chrome driver). A workaround to this problem is simply scrolling to the element, however the examples shown are in Java, not JavaScript. Based on the solutions for java I tried the following without success:
var element = driver.findElement(webdriver.By.id('next_button'));
var location = element.getLocation();
var window = new webdriver.Window(driver);
window.scrollBy(location);
I don't think I'm using the right type of window object here. How do I scroll down to the element using JavaScript?