Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我面临着使用SeleniumJava在html5中进行拖放的问题_Java_Html_Selenium_Selenium Webdriver_Drag And Drop - Fatal编程技术网

我面临着使用SeleniumJava在html5中进行拖放的问题

我面临着使用SeleniumJava在html5中进行拖放的问题,java,html,selenium,selenium-webdriver,drag-and-drop,Java,Html,Selenium,Selenium Webdriver,Drag And Drop,我是java和selenium的新手。我在HTML5的dragAndDrop中面临问题。你能帮帮我吗 我使用的代码是: public static void draganddrop(WebDriver driver ,WebElement Source, WebElement Destination) { Actions action = new Actions(driver); action.dragAndDrop(Source, Destination).build().pe

我是java和selenium的新手。我在HTML5的
dragAndDrop
中面临问题。你能帮帮我吗

我使用的代码是:

public static void draganddrop(WebDriver driver ,WebElement Source, WebElement Destination) 
  {

  Actions action = new Actions(driver);
  action.dragAndDrop(Source, Destination).build().perform();

  }

  • 通过
    操作
    界面尝试我的
    拖放版

    new Actions(driver)
        .moveToElement(source)
        .pause(Duration.ofSeconds(1))
        .clickAndHold(source)
        .pause(Duration.ofSeconds(1))
        .moveByOffset(1, 0)
        .moveToElement(destination)
        .moveByOffset(1, 0)
        .pause(Duration.ofSeconds(1))
        .release().perform();
    

    在我的应用程序中,当我单击并按住
    时,目标元素会更改。这就是我添加暂停的原因。

    这是硒和Html5尚未解决的老问题;但您可以在这里找到一个解决方案(归功于rcorreia):


    只需执行js文件
    js.ExecuteScript(jsfile+“$('#[sourceElement]')。simulateDragDrop({dropTarget:'#[targetElement]'))

    不,除非您显示代码并清楚地说明您面临的具体问题,否则我们无法帮助您。我在webdriver中使用简单的拖放功能进行了尝试,它选择了源,但没有拖放到目标。您可以使用Action classi尝试过但没有工作-public static void draganddop(WebDriver驱动程序,WebElement源,WebElement目标){Actions action=新操作(驱动程序);action.dragAndDrop(源,目标).build().perform();相关HTMLplease@vaishali它有什么作用吗?将鼠标移动到元素?单击并按住但不释放?请提供更多信息:)它单击了可拖动的元素,但没有放到该位置