Selenium WebDriver-无法在IE11中拖放元素

问题描述 投票:0回答:1

我正在尝试从侧面板拖放元素以形成表单。我写的代码如下所示。

Actions builder = new Actions(driver);
builder.dragAndDrop(source, target).build().perform();

这在除IE11之外的所有浏览器中都可以正常工作。

我尝试过其他方法,例如

方法1-

builder.clickAndHold(source)
        .moveToElement(target)
        .release(target)
        .build()
        .perform();

方法2-

builder.clickAndHold(source)
    .pause(Duration.ofSeconds(1))
    .moveByOffset(-1, -1)
    .pause(Duration.ofSeconds(1))
    .moveToElement(target)
    .pause(Duration.ofSeconds(1))
    .moveToElement(target)
    .pause(Duration.ofSeconds(1))
    .release(target)
    .build()
    .perform();

但没有任何作用。

以上所有选项在页面上不执行任何操作,但它们正在执行而没有任何错误。我还尝试了在不同stackoverflow / gitHub链接中提供的所有javascript解决方案,但没有任何效果。

有人可以帮我吗?

谢谢,Chandresh Parmar

javascript selenium selenium-webdriver internet-explorer-11
1个回答
0
投票

似乎是IE11的一个已知问题,没有人能够解决。

[Selenium存储库中存在一个相关的GitHub问题,但由于缺少可复制的示例而已被关闭:

https://github.com/SeleniumHQ/selenium/issues/6354

[StackExchange上的其他用户自2016年以来一直遇到此问题,但没有实际解决方案:

Unable to Automate Drag and Drop for IE11 : Selenium WebDriver(无工作分辨率)

[https://sqa.stackexchange.com/questions/22534/why-drag-and-drop-is-not-working-in-selenium-webdriver/26500(没有接受的答案,但有一个反对意见)]

我的猜测是IE驱动程序很不稳定,由于未知原因,拖放可能在某些网站上有效,而在其他网站上则无效。您可能会比较幸运,可以在Selenium存储库中打开GitHub问题,并提供一个工作代码示例/ URL,始终无法进行拖放操作。

© www.soinside.com 2019 - 2024. All rights reserved.