繁体   English   中英

selenium java拖放 - 尝试拖放

[英]selenium java drag and drop - trying to drag and drop

我正在尝试将 draggable 1 拖放到这里框。 Draggable 1 可以被点击并按住,但不能拖动到下拉框。 任何帮助,将不胜感激。

    WebDriver driver = new ChromeDriver();
    driver.get("https://www.seleniumeasy.com/test/drag-and-drop-demo.html");

    WebElement from = driver.findElement(By.xpath("//*[@id=\"todrag\"]/span[" + n + "]"));
    WebElement to = driver.findElement(By.xpath("//div[@dropzone]"));
    Actions act = new Actions(driver);
    act.clickAndHold(from).moveToElement(to).release(to).build().perform();
    }

尝试操作拖放方法来实现上述功能。 您的 xpath 也不正确。 请参考以下正确的xpath:

  //span[contains(text(),'Draggable'"+ n +"')] 
  //div[@id='mydropzone']

拖放

Actions act=new Actions(driver);                    
act.dragAndDrop(From, To).build().perform()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM