Java 如何在selenium网格中执行拖放

Java 如何在selenium网格中执行拖放,java,selenium,Java,Selenium,我已成功安装selenium grid,但无法在selenium grid中执行拖放操作。如果我在testng中运行代码,它将按预期工作,但对于网格,它将失败,因此无法修复此问题 jar:selenium-server-standalone-2.45.0.jar Selenium罐子:“Selenium-2.45.0”中的所有罐子(最新版本) 代码: 例外情况: java.lang.ClassCastException:org.openqa.selenium.remote.RemoteWebDr

我已成功安装selenium grid,但无法在selenium grid中执行拖放操作。如果我在testng中运行代码,它将按预期工作,但对于网格,它将失败,因此无法修复此问题

jar:selenium-server-standalone-2.45.0.jar

Selenium罐子:“Selenium-2.45.0”中的所有罐子(最新版本)

代码:

例外情况:

java.lang.ClassCastException:org.openqa.selenium.remote.RemoteWebDriver无法强制转换为org.openqa.selenium.interactions.HasInputDevices 位于org.openqa.selenium.interactions.Actions.(Actions.java:41) 位于qa.DragdropElements.DragdropElements1(DragdropElements.java:45) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 位于sun.reflect.NativeMethodAccessorImpl.invoke(未知源)


试试这个,可能会有用

Actions actionsBuilder = new Actions(driver);
builder.keyDown(Keys.CONTROL)
   .click(elementName)
   .keyUp(Keys.CONTROL);
Action action = actionsBuilder.build();
action.perform();   

不知道为什么拖放不适合你。如果您在节点中运行多线程,请尝试使用单线程运行。另外,值得一提的是您的节点操作系统信息。

这是
驱动程序部分的演员阵容问题。他将其创建为
RemoteWebDriver
,而不是
FirefoxDriver
。您好,用户1629109,感谢您查看它
不幸的是,提供的代码不起作用
如果您需要我这边的更多信息,请告诉我。@Girish:在原始代码中尝试添加FirefoxProfile profile=new ProfilesIni().getProfile(“默认”);profile.setenablenactiveEvents(true);然后将配置文件传递给capabilities@user1629109我尝试了FirefoxProfile,得到了与以前相同的结果。它不起作用。嘿,伙计们,这方面有什么更新吗,如果有人有java脚本也能为我工作的话。是HTML5吗?那么拖放不起作用已经是一个公开的问题了@谢谢Unalgosar先生,请告诉我修复完成后的情况。
Actions actionsBuilder = new Actions(driver);
builder.keyDown(Keys.CONTROL)
   .click(elementName)
   .keyUp(Keys.CONTROL);
Action action = actionsBuilder.build();
action.perform();