我在JavaScript中创建了一些Selenium测试。点击不在视图中的按钮时遇到问题(这似乎是Chrome驱动程序的问题)。解决此问题的方法很简单,只是scrolling to the element,但是所示的示例是使用Java而不是JavaScript。基于java的解决方案,我尝试了以下没有成功:使用JavaScript在Selenium上使用JavaScript滚动到网页元素
var element = driver.findElement(webdriver.By.id('next_button'));
var location = element.getLocation();
var window = new webdriver.Window(driver);
window.scrollBy(location);
我不认为我在这里使用正确类型的窗口对象。如何使用JavaScript向下滚动到元素?
[How to go to a specific element on page?](http://stackoverflow.com/questions/4801655/how-to-go-to-a-specific-element-on-page) – JeffC
看看这个答案,http://stackoverflow.com/a/14732703/2386774。它是JavaScript。 – JeffC