【问题标题】:Chrome Drag and Drop not working for Canvas Element with Selenium Action ClassesChrome 拖放不适用于具有 Selenium 操作类的 Canvas 元素
【发布时间】:2017-07-11 06:28:58
【问题描述】:

我正在使用 Selenium 2.53.1、Selenium Support Class 2.53.1 和 Chrome 版本 59.0.3071.115 和 Chrome 驱动程序 2.30。似乎拖放操作不适用于 Chrome,但适用于 Firefox。它一直工作到昨天,但突然停止工作,我检查了一些升级是否破坏了它的工作,但它看起来不像。以下是我的代码:

 public void DragAndDrop(IWebDriver driver, By source, By destination, int sourceX, int sourceY, int destinationX, int destinationY)
        {
            try
            {
                IWebElement sourceElement = FindElement(driver, source);
                IWebElement destinationElement = FindElement(driver, destination);
                Actions Actions = new Actions(driver);
                Actions.MoveToElement(sourceElement, sourceX, sourceY).ClickAndHold().Build().Perform();
                Actions.MoveByOffset(5, 0);
                Actions.MoveToElement(destinationElement, destinationX, destinationY).Release().Build().Perform();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }

【问题讨论】:

    标签: google-chrome selenium automation


    【解决方案1】:

    检查 sourceX 和 sourceY 是否正确。

    如果正确,请使用 dragAndDropBy(sources, xInteger, yInteger)。

    【讨论】:

    • Source X 和 Y 是正确的,这就是它在 Firefox 中工作的原因,我将元素从一个画布(HTML5 元素)拖到另一个画布,所以我不能使用它。
    【解决方案2】:

    与您的情况类似,我的脚本一夜之间停止工作。 降级 Chromedriver 是一种临时解决方案。

    【讨论】:

    • 请不要在回答中提问,您需要为此使用 cmets,通过为社区做出贡献,快速获得 50 个代表。
    • 您降级到哪个 chrome 驱动程序?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-02
    相关资源
    最近更新 更多