无法在firefox中拖放元素,抛出“buttondown
”超时,即使目标元素可见,启用,显示
在Chrome上,代码会毫无例外地执行,但不会执行操作。
Actions actions = new Actions(BrowserClass.WebDriver);
var src = BrowserClass.WebDriver.FindElement(By.XPath("//div[contains(@class,'box-padding')]/ul/li[11]/div/div/div"));
var dest = BrowserClass.WebDriver.FindElement(By.CssSelector("div[id*='row-cxs-control-2']>div>div>div>div>div:nth-child(1)>div"));
actions.ClickAndHold(src);
try {
System.Threading.Thread.Sleep(1000);
} catch (Exception e) {
var s = e.StackTrace;
}
actions.MoveToElement(dest).Release(dest).Build();
actions.Perform();
答案 0 :(得分:0)
错误的拖动方式可能是一个原因。改变
actions.MoveToElement(dest).Release(dest).Build(); //seems incorrect to release `dest` here
actions.Perform();
以下任何一个:
actions.DragAndDrop(src,dest).Build().Perform();
或者
actions.ClickAndHold(src).MoveToElement(dest).Release().Build().Perform();