Chrome中的Selenium Web驱动程序DragAndDropToOffset无法正常工作吗? [英] Selenium Web Driver DragAndDropToOffset in Chrome not working?

查看:379
本文介绍了Chrome中的Selenium Web驱动程序DragAndDropToOffset无法正常工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 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.有什么想法吗?与其拖动我的资源,不如干脆什么都没做(至少可见).

This code works in Internet Explorer and Firefox, but not Chrome. Any ideas on why? Instead of dragging my sources, it is simply just doing nothing (visible that I can see, at least).

推荐答案

似乎Webdriver的拖放存在一些问题.

Seems like there are some issue with drag and drop in 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();     

这篇关于Chrome中的Selenium Web驱动程序DragAndDropToOffset无法正常工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆