Selenium Web驱动程序未执行拖放操作,因此断言每次都会失败,因为在拖放可拖动项之后在拖放列表中找不到文本。我已经添加了可拖动项目,dropzone和放置列表的屏幕截图,有人可以建议我如何解决此问题吗?
//下面是类中的两个方法dragAnItem()和dropItem();
function generateHtml(template, data){
const rendered = new Vue({template, data}).$mount()
return rendered.$el
}
// DragAndDropTest如下;
public class DragAndDrop {
WebDriver driver;
public DragAndDrop(WebDriver driver){
this.driver = driver;
}
public void dragAnItem(){
//Element on which need to drag.
WebElement source = driver.findElement(By.xpath("//div[@id='todrag']/span"));
//Element on which need to drop.
WebElement target =driver.findElement(By.id("mydropzone"));
try {
Thread.sleep(5000);
//Using Actions class for drag and drop.
Actions act = new Actions(driver);
//Using Action for Dragged and dropped.
Action dragAndDrop = act.clickAndHold(source)
.moveToElement(target)
.release(target)
.build();
dragAndDrop.perform();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String droppedItem(){
return driver.findElement(By.id("droppedlist")).getText();
//return driver.findElement(By.xpath("//div[@id='droppedlist']")).getText();
}
}