我正在做一個執行拖放操作的測試。如何正確模擬硒中的拖放
我當前的代碼:
WebElement element;
By mainSelector, secondarySelector;
Actions action;
action = new Actions(driver);
mainSelector = By.cssSelector("tbody.naam tr:nth-child(1) td:nth-child(1)");
secondarySelector = By.cssSelector("tbody.bedrijf tr:nth-child(1) td:nth-child(1)");
action.click(driver.findElement(mainSelector));
action.clickAndHold(driver.findElement(mainSelector))
.moveToElement(driver.findElement(secondarySelector), 5, 5)
.perform();
action.release(driver.findElement(secondarySelector));
action.perform();
action.dragAndDropBy(driver.findElement(mainSelector), 300, 300).perform();
action.dragAndDrop(driver.findElement(mainSelector), driver.findElement(secondarySelector)).perform();
但是,這並不做任何事情。 我已經添加了多個執行,因此請確保這不是問題。 我已經添加了一個偏移量,因爲我讀到這有時是越野車。 我用firefox進行測試。
請檢查:http://stackoverflow.com/questions/14210051/how-to-automate-drag-drop-functionality-using-selenium-web-driver – 2014-12-08 09:09:32