我正在尝试使用Selenium WebDriver将元素拖动到另一个元素中,但它无法正常工作。 我们尝试了不同的解决方案,如下所述:
应用程序建立在Anjular4
上WebElement From = (driver.findElement(By.xpath("")));
WebElement To = (driver.findElement(By.xpath("//*[@id='avpContainer']"));
Actions builder = new Actions(driver);
builder.clickAndHold(From).moveToElement(To).click(To).release().build().perform();
WebElement From = (driver.findElement(By.xpath("")));
WebElement To = (driver.findElement(By.xpath("//*[@id='avpContainer']"));
Actions builder = new Actions(driver);
builder.clickAndHold(From).release(To).build().perform();
WebElement From = (driver.findElement(By.xpath("")));
WebElement To = (driver.findElement(By.xpath("//*[@id='avpContainer']"));
Actions builder = new Actions(driver);
builder.dragAndDrop(From, To).build().perform();
//Setup robot
Robot robot = new Robot();
robot.setAutoDelay(50);
//Maximized browser:
robot.keyPress(KeyEvent.VK_F11);
Thread.sleep(2000);
WebElement dragElement = d.findElement('drag element');
Actions builder = new Actions(d);
builder.dragAndDropBy(dragElement,x, y).build().perform();
任何人都可以帮忙解决此问题。
答案 0 :(得分:0)
WebElement From = driver.findElement(By.xpath(""));
WebElement To = driver.findElement(By.xpath(""));
Actions builder = new Actions(driver);
Action dragAndDrop = builder.clickAndHold(From)
.moveToElement(To)
.release(To)
.build();
dragAndDrop.perform();
答案 1 :(得分:0)
如果应用程序是在HTML5上构建的,则拖放功能将无效。
因此,我们可以在draganddrop.js
的支持下完成这项工作