WebDriver 里的拖拽实现

来源:互联网 发布:家装平面设计软件 编辑:程序博客网 时间:2024/06/05 20:41
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 yourselflike suchAction dragAllTheWayUp = builder.MoveToElement(resizeHandle).ClickAndHold().MoveByOffset(x, y).Release().Build();dragAllTheWayUp.perform();

	
				
		
原创粉丝点击