简体   繁体   English

Webdriver-actions.draganddrop在w3schools页面中不起作用

[英]Webdriver - actions.draganddrop not working in w3schools page

The dragAndDrop of Actions is not working on the w3schools page: w3schools页面上的dragAndDrop of Actions不起作用:

same code works on other page 相同代码可在其他页面上使用

Here is the code that i tried. 这是我尝试过的代码。

WebDriver driver = new FirefoxDriver();
driver.get("http://www.w3schools.com/html/html5_draganddrop.asp");
driver.manage().window().maximize();
Actions actions = new Actions(driver);
actions.dragAndDrop(driver.findElement(By.id("div1")), driver.findElement(By.id("div2"))).build().perform();

You're close.. You need to find the element that has the ondragstart attribute. 您将要关闭。.您需要找到具有ondragstart属性的元素。 The image is what has the attribute. 图像就是具有属性的东西。 Not the <div> 不是<div>

Try: 尝试:

...
actions.dragAndDrop(driver.findElement(By.id("drag1")), driver.findElement(By.id("div2"))).build().perform();

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

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