以下是代码。拖放不起作用。请告诉我代码中的错误。
WebDriver driver = new FirefoxDriver();
String URL ="http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_draganddrop";
driver.get(URL);
driver.manage().window().maximize();
WebDriverWait frame_Test = new WebDriverWait(driver, 10);
frame_Test.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("iframeResult")));
WebElement From = driver.findElement(By.xpath("//img[@id='drag1']"));
WebElement To =driver.findElement(By.xpath("//div[@id='div1']"));
Actions builder = new Actions(driver);
builder.clickAndHold(From).moveToElement(To).release(From).build( ).perform();
答案 0 :(得分:0)
WebElement element = driver.findElement(By.name("source"));
WebElement target = driver.findElement(By.name("target"));
(new Actions(driver)).dragAndDrop(element, target).perform();