2013-08-30 52 views
0

我在使用IE10中的Webdriver方法moveto时遇到问题。 我打算做的是滚动一个当前不可见的项目,它位于溢出的div中。使用Selenium在IE10中移动元素

HTML例如:

<div id="container" style="height: 500px; width: 200px; overflow: auto;"> 
    <div id="first" style="height: 1000px; width: 200px; background-color: red;"></div> 
    <div id="second" style="height: 200px; width: 200px; background-color: green;"></div> 
</div> 

在上述我想的#second元件上使用通过MoveTo的例子。这在Firefox中运行得很好,但IE10中没有。我使用WebDriverJs和Selenium 2.33.0。

回答

0

使用下面的代码滚动到元素

JavascriptExecutor jse = (JavascriptExecutor)driver; 
jse.executeScript("window.scrollBy(0,2000)", ""); 

向下滚动到元素。

向上滚动做

JavascriptExecutor jse = (JavascriptExecutor)driver; 
jse.executeScript("window.scrollBy(2000,0)", ""); 
+0

我认为这太,但我宁愿做没有的JavaScript。它不应该与moveto一起工作吗? – jonte