`
aerchi
  • 浏览: 425612 次
  • 性别: Icon_minigender_1
  • 来自: 昆明
文章分类
社区版块
存档分类
最新评论

WebDriver 里的拖拽实现

 
阅读更多
I am having intermittent issues when doing drag & drop operations with ChromeDriver. Here is an excerpt from the code that causes the problem:

WebElement resizeHandle = wd.findElement(By.xpath("//section[@id='fullscreenView']//div[contains(@class,'resizeHandle')]"));
Actions builder = new Actions(wd);
Action dragAllTheWayUp = builder.dragAndDropBy(resizeHandle, 0, -200).build();
dragAllTheWayUp.perform();

Unfotunately I can not provide a real test case as the tested web application is not publicly available.
The idea of the code is to drag a div (which works as a resize handle in the application) up in the browser. This works perfectly with IE and with Firefox, but in Chrome around 1 of 4 times the div seems to be dragged down (i.e. as if positive offset was given in the dragAndDropBy() method)


hello, 
dragAndDropTo() doesn't work for me in the chrome driver very well. if it tries to drag to somewhere outside of the current viewing window it gives me funny results, like dragging in an incorrect direction.
if you can't fix it you might try building the steps of the drag and drop yourself

like such

Action dragAllTheWayUp = builder.MoveToElement(resizeHandle)
.ClickAndHold()
.MoveByOffset(x, y)
.Release()
.Build();

dragAllTheWayUp.perform();





  


  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics