private static void DragAndDropToOffset(IWebDriver driver, IWebElement source, int xposOffset, int yposOffset)
{
Actions mouseActionBuilder = new Actions(driver);
mouseActionBuilder.DragAndDropToOffset(source, xposOffset, yposOffset).Build().Perform();
}
此代码适用于Internet Explorer和Firefox,但不适用于Chrome。有什么想法吗?它不是拖动我的来源,而是简单地什么也不做(至少可见我可以看到)。
答案 0 :(得分:0)
似乎在Webdriver中拖放存在一些问题。
您可以尝试更改代码:
WebElement sourceElement = <find an element from source location>;
WebElement targetElement = <find an element from target location>;
Actions mouseActionBuilder = new Actions(driver);
Actions dragAndDrop = mouseActionBuilder.clickAndHold(sourceElement).moveToElement(targetElement).release(targetElement);
dragAndDrop.Build().Perform();